Skip to content

Commit

Permalink
[OTEL-2359] Add otel releted metric origins
Browse files Browse the repository at this point in the history
  • Loading branch information
songy23 committed Jan 14, 2025
1 parent 17111e2 commit a9985e3
Show file tree
Hide file tree
Showing 4 changed files with 316 additions and 10 deletions.
217 changes: 217 additions & 0 deletions pkg/metrics/metricsource.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,51 @@ const (
MetricSourceMilvus
MetricSourceNvidiaNim
MetricSourceQuarkus

// OpenTelemetry Collector receivers
MetricSourceOpenTelemetryCollectorUnknown
MetricSourceOpenTelemetryCollectorDockerstatsReceiver
MetricSourceOpenTelemetryCollectorElasticsearchReceiver
MetricSourceOpenTelemetryCollectorExpvarReceiver
MetricSourceOpenTelemetryCollectorFilestatsReceiver
MetricSourceOpenTelemetryCollectorFlinkmetricsReceiver
MetricSourceOpenTelemetryCollectorGitproviderReceiver
MetricSourceOpenTelemetryCollectorHaproxyReceiver
MetricSourceOpenTelemetryCollectorHostmetricsReceiver
MetricSourceOpenTelemetryCollectorHttpcheckReceiver
MetricSourceOpenTelemetryCollectorIisReceiver
MetricSourceOpenTelemetryCollectorK8sclusterReceiver
MetricSourceOpenTelemetryCollectorKafkametricsReceiver
MetricSourceOpenTelemetryCollectorKubeletstatsReceiver
MetricSourceOpenTelemetryCollectorMemcachedReceiver
MetricSourceOpenTelemetryCollectorMongodbatlasReceiver
MetricSourceOpenTelemetryCollectorMongodbReceiver
MetricSourceOpenTelemetryCollectorMysqlReceiver
MetricSourceOpenTelemetryCollectorNginxReceiver
MetricSourceOpenTelemetryCollectorNsxtReceiver
MetricSourceOpenTelemetryCollectorOracledbReceiver
MetricSourceOpenTelemetryCollectorPostgresqlReceiver
MetricSourceOpenTelemetryCollectorPrometheusReceiver
MetricSourceOpenTelemetryCollectorRabbitmqReceiver
MetricSourceOpenTelemetryCollectorRedisReceiver
MetricSourceOpenTelemetryCollectorRiakReceiver
MetricSourceOpenTelemetryCollectorSaphanaReceiver
MetricSourceOpenTelemetryCollectorSnmpReceiver
MetricSourceOpenTelemetryCollectorSnowflakeReceiver
MetricSourceOpenTelemetryCollectorSplunkenterpriseReceiver
MetricSourceOpenTelemetryCollectorSqlserverReceiver
MetricSourceOpenTelemetryCollectorSshcheckReceiver
MetricSourceOpenTelemetryCollectorStatsdReceiver
MetricSourceOpenTelemetryCollectorVcenterReceiver
MetricSourceOpenTelemetryCollectorZookeeperReceiver
MetricSourceOpenTelemetryCollectorActiveDirectorydsReceiver
MetricSourceOpenTelemetryCollectorAerospikeReceiver
MetricSourceOpenTelemetryCollectorApacheReceiver
MetricSourceOpenTelemetryCollectorApachesparkReceiver
MetricSourceOpenTelemetryCollectorAzuremonitorReceiver
MetricSourceOpenTelemetryCollectorBigipReceiver
MetricSourceOpenTelemetryCollectorChronyReceiver
MetricSourceOpenTelemetryCollectorCouchdbReceiver
)

// String returns a string representation of MetricSource
Expand Down Expand Up @@ -882,6 +927,92 @@ func (ms MetricSource) String() string {
return "milvus"
case MetricSourceQuarkus:
return "quarkus"
case MetricSourceOpenTelemetryCollectorUnknown:
return "opentelemetry_collector_unknown"
case MetricSourceOpenTelemetryCollectorDockerstatsReceiver:
return "opentelemetry_collector_dockerstatsreceiver"
case MetricSourceOpenTelemetryCollectorElasticsearchReceiver:
return "opentelemetry_collector_elasticsearchreceiver"
case MetricSourceOpenTelemetryCollectorExpvarReceiver:
return "opentelemetry_collector_expvarreceiver"
case MetricSourceOpenTelemetryCollectorFilestatsReceiver:
return "opentelemetry_collector_filestatsreceiver"
case MetricSourceOpenTelemetryCollectorFlinkmetricsReceiver:
return "opentelemetry_collector_flinkmetricsreceiver"
case MetricSourceOpenTelemetryCollectorGitproviderReceiver:
return "opentelemetry_collector_gitproviderreceiver"
case MetricSourceOpenTelemetryCollectorHaproxyReceiver:
return "opentelemetry_collector_haproxyreceiver"
case MetricSourceOpenTelemetryCollectorHostmetricsReceiver:
return "opentelemetry_collector_hostmetricsreceiver"
case MetricSourceOpenTelemetryCollectorHttpcheckReceiver:
return "opentelemetry_collector_httpcheckreceiver"
case MetricSourceOpenTelemetryCollectorIisReceiver:
return "opentelemetry_collector_iisreceiver"
case MetricSourceOpenTelemetryCollectorK8sclusterReceiver:
return "opentelemetry_collector_k8sclusterreceiver"
case MetricSourceOpenTelemetryCollectorKafkametricsReceiver:
return "opentelemetry_collector_kafkametricsreceiver"
case MetricSourceOpenTelemetryCollectorKubeletstatsReceiver:
return "opentelemetry_collector_kubeletstatsreceiver"
case MetricSourceOpenTelemetryCollectorMemcachedReceiver:
return "opentelemetry_collector_memcachedreceiver"
case MetricSourceOpenTelemetryCollectorMongodbatlasReceiver:
return "opentelemetry_collector_mongodbatlasreceiver"
case MetricSourceOpenTelemetryCollectorMongodbReceiver:
return "opentelemetry_collector_mongodbreceiver"
case MetricSourceOpenTelemetryCollectorMysqlReceiver:
return "opentelemetry_collector_mysqlreceiver"
case MetricSourceOpenTelemetryCollectorNginxReceiver:
return "opentelemetry_collector_nginxreceiver"
case MetricSourceOpenTelemetryCollectorNsxtReceiver:
return "opentelemetry_collector_nsxtreceiver"
case MetricSourceOpenTelemetryCollectorOracledbReceiver:
return "opentelemetry_collector_oracledbreceiver"
case MetricSourceOpenTelemetryCollectorPostgresqlReceiver:
return "opentelemetry_collector_postgresqlreceiver"
case MetricSourceOpenTelemetryCollectorPrometheusReceiver:
return "opentelemetry_collector_prometheusreceiver"
case MetricSourceOpenTelemetryCollectorRabbitmqReceiver:
return "opentelemetry_collector_rabbitmqreceiver"
case MetricSourceOpenTelemetryCollectorRedisReceiver:
return "opentelemetry_collector_redisreceiver"
case MetricSourceOpenTelemetryCollectorRiakReceiver:
return "opentelemetry_collector_riakreceiver"
case MetricSourceOpenTelemetryCollectorSaphanaReceiver:
return "opentelemetry_collector_saphanareceiver"
case MetricSourceOpenTelemetryCollectorSnmpReceiver:
return "opentelemetry_collector_snmpreceiver"
case MetricSourceOpenTelemetryCollectorSnowflakeReceiver:
return "opentelemetry_collector_snowflakereceiver"
case MetricSourceOpenTelemetryCollectorSplunkenterpriseReceiver:
return "opentelemetry_collector_splunkenterprisereceiver"
case MetricSourceOpenTelemetryCollectorSqlserverReceiver:
return "opentelemetry_collector_sqlserverreceiver"
case MetricSourceOpenTelemetryCollectorSshcheckReceiver:
return "opentelemetry_collector_sshcheckreceiver"
case MetricSourceOpenTelemetryCollectorStatsdReceiver:
return "opentelemetry_collector_statsdreceiver"
case MetricSourceOpenTelemetryCollectorVcenterReceiver:
return "opentelemetry_collector_vcenterreceiver"
case MetricSourceOpenTelemetryCollectorZookeeperReceiver:
return "opentelemetry_collector_zookeeperreceiver"
case MetricSourceOpenTelemetryCollectorActiveDirectorydsReceiver:
return "opentelemetry_collector_activedirectorydsreceiver"
case MetricSourceOpenTelemetryCollectorAerospikeReceiver:
return "opentelemetry_collector_aerospikereceiver"
case MetricSourceOpenTelemetryCollectorApacheReceiver:
return "opentelemetry_collector_apachereceiver"
case MetricSourceOpenTelemetryCollectorApachesparkReceiver:
return "opentelemetry_collector_apachesparkreceiver"
case MetricSourceOpenTelemetryCollectorAzuremonitorReceiver:
return "opentelemetry_collector_azuremonitorreceiver"
case MetricSourceOpenTelemetryCollectorBigipReceiver:
return "opentelemetry_collector_bigipreceiver"
case MetricSourceOpenTelemetryCollectorChronyReceiver:
return "opentelemetry_collector_chronyreceiver"
case MetricSourceOpenTelemetryCollectorCouchdbReceiver:
return "opentelemetry_collector_couchdbreceiver"
default:
return "<unknown>"
}
Expand Down Expand Up @@ -1426,6 +1557,92 @@ func CheckNameToMetricSource(name string) MetricSource {
return MetricSourceMilvus
case "quarkus":
return MetricSourceQuarkus
case "opentelemetry_collector_unknown":
return MetricSourceOpenTelemetryCollectorUnknown
case "opentelemetry_collector_dockerstatsreceiver":
return MetricSourceOpenTelemetryCollectorDockerstatsReceiver
case "opentelemetry_collector_elasticsearchreceiver":
return MetricSourceOpenTelemetryCollectorElasticsearchReceiver
case "opentelemetry_collector_expvarreceiver":
return MetricSourceOpenTelemetryCollectorExpvarReceiver
case "opentelemetry_collector_filestatsreceiver":
return MetricSourceOpenTelemetryCollectorFilestatsReceiver
case "opentelemetry_collector_flinkmetricsreceiver":
return MetricSourceOpenTelemetryCollectorFlinkmetricsReceiver
case "opentelemetry_collector_gitproviderreceiver":
return MetricSourceOpenTelemetryCollectorGitproviderReceiver
case "opentelemetry_collector_haproxyreceiver":
return MetricSourceOpenTelemetryCollectorHaproxyReceiver
case "opentelemetry_collector_hostmetricsreceiver":
return MetricSourceOpenTelemetryCollectorHostmetricsReceiver
case "opentelemetry_collector_httpcheckreceiver":
return MetricSourceOpenTelemetryCollectorHttpcheckReceiver
case "opentelemetry_collector_iisreceiver":
return MetricSourceOpenTelemetryCollectorIisReceiver
case "opentelemetry_collector_k8sclusterreceiver":
return MetricSourceOpenTelemetryCollectorK8sclusterReceiver
case "opentelemetry_collector_kafkametricsreceiver":
return MetricSourceOpenTelemetryCollectorKafkametricsReceiver
case "opentelemetry_collector_kubeletstatsreceiver":
return MetricSourceOpenTelemetryCollectorKubeletstatsReceiver
case "opentelemetry_collector_memcachedreceiver":
return MetricSourceOpenTelemetryCollectorMemcachedReceiver
case "opentelemetry_collector_mongodbatlasreceiver":
return MetricSourceOpenTelemetryCollectorMongodbatlasReceiver
case "opentelemetry_collector_mongodbreceiver":
return MetricSourceOpenTelemetryCollectorMongodbReceiver
case "opentelemetry_collector_mysqlreceiver":
return MetricSourceOpenTelemetryCollectorMysqlReceiver
case "opentelemetry_collector_nginxreceiver":
return MetricSourceOpenTelemetryCollectorNginxReceiver
case "opentelemetry_collector_nsxtreceiver":
return MetricSourceOpenTelemetryCollectorNsxtReceiver
case "opentelemetry_collector_oracledbreceiver":
return MetricSourceOpenTelemetryCollectorOracledbReceiver
case "opentelemetry_collector_postgresqlreceiver":
return MetricSourceOpenTelemetryCollectorPostgresqlReceiver
case "opentelemetry_collector_prometheusreceiver":
return MetricSourceOpenTelemetryCollectorPrometheusReceiver
case "opentelemetry_collector_rabbitmqreceiver":
return MetricSourceOpenTelemetryCollectorRabbitmqReceiver
case "opentelemetry_collector_redisreceiver":
return MetricSourceOpenTelemetryCollectorRedisReceiver
case "opentelemetry_collector_riakreceiver":
return MetricSourceOpenTelemetryCollectorRiakReceiver
case "opentelemetry_collector_saphanareceiver":
return MetricSourceOpenTelemetryCollectorSaphanaReceiver
case "opentelemetry_collector_snmpreceiver":
return MetricSourceOpenTelemetryCollectorSnmpReceiver
case "opentelemetry_collector_snowflakereceiver":
return MetricSourceOpenTelemetryCollectorSnowflakeReceiver
case "opentelemetry_collector_splunkenterprisereceiver":
return MetricSourceOpenTelemetryCollectorSplunkenterpriseReceiver
case "opentelemetry_collector_sqlserverreceiver":
return MetricSourceOpenTelemetryCollectorSqlserverReceiver
case "opentelemetry_collector_sshcheckreceiver":
return MetricSourceOpenTelemetryCollectorSshcheckReceiver
case "opentelemetry_collector_statsdreceiver":
return MetricSourceOpenTelemetryCollectorStatsdReceiver
case "opentelemetry_collector_vcenterreceiver":
return MetricSourceOpenTelemetryCollectorVcenterReceiver
case "opentelemetry_collector_zookeeperreceiver":
return MetricSourceOpenTelemetryCollectorZookeeperReceiver
case "opentelemetry_collector_activedirectorydsreceiver":
return MetricSourceOpenTelemetryCollectorActiveDirectorydsReceiver
case "opentelemetry_collector_aerospikereceiver":
return MetricSourceOpenTelemetryCollectorAerospikeReceiver
case "opentelemetry_collector_apachereceiver":
return MetricSourceOpenTelemetryCollectorApacheReceiver
case "opentelemetry_collector_apachesparkreceiver":
return MetricSourceOpenTelemetryCollectorApachesparkReceiver
case "opentelemetry_collector_azuremonitorreceiver":
return MetricSourceOpenTelemetryCollectorAzuremonitorReceiver
case "opentelemetry_collector_bigipreceiver":
return MetricSourceOpenTelemetryCollectorBigipReceiver
case "opentelemetry_collector_chronyreceiver":
return MetricSourceOpenTelemetryCollectorChronyReceiver
case "opentelemetry_collector_couchdbreceiver":
return MetricSourceOpenTelemetryCollectorCouchdbReceiver
default:
return MetricSourceUnknown
}
Expand Down
6 changes: 1 addition & 5 deletions pkg/serializer/internal/metrics/iterable_series.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,6 @@ func (pb *PayloadsBuilder) writeSerie(serie *metrics.Serie) error {
const serieMetadataOriginOriginService = 6
// |----| 'Origin' message
// |-----------| 'origin_service' field index
const serieMetadataOriginOriginProductAgentType = 10
// |----| 'Origin' message
// |-----------| 'OriginProduct' enum
// |-------| 'Agent' enum value

addToPayload := func() error {
err := pb.compressor.AddItem(pb.buf.Bytes())
Expand Down Expand Up @@ -409,7 +405,7 @@ func (pb *PayloadsBuilder) writeSerie(serie *metrics.Serie) error {
return err
}
}
err = ps.Int32(serieMetadataOriginOriginProduct, serieMetadataOriginOriginProductAgentType)
err = ps.Int32(serieMetadataOriginOriginProduct, metricSourceToOriginProduct(serie.Source))
if err != nil {
return err
}
Expand Down
97 changes: 97 additions & 0 deletions pkg/serializer/internal/metrics/origin_mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ import (
"github.com/DataDog/datadog-agent/pkg/metrics"
)

func metricSourceToOriginProduct(ms metrics.MetricSource) int32 {
const serieMetadataOriginOriginProductAgentType = 10
const serieMetadataOriginOriginProductDatadogExporterType = 19
if ms >= metrics.MetricSourceOpenTelemetryCollectorUnknown && ms <= metrics.MetricSourceOpenTelemetryCollectorCouchdbReceiver {
return serieMetadataOriginOriginProductDatadogExporterType
}
return serieMetadataOriginOriginProductAgentType
}

func metricSourceToOriginCategory(ms metrics.MetricSource) int32 {
// These constants map to specific fields in the 'OriginCategory' enum in origin.proto
switch ms {
Expand Down Expand Up @@ -711,6 +720,94 @@ func metricSourceToOriginService(ms metrics.MetricSource) int32 {
return 203
case metrics.MetricSourceInternal:
return 212

case metrics.MetricSourceOpenTelemetryCollectorUnknown:
return 0
case metrics.MetricSourceOpenTelemetryCollectorDockerstatsReceiver:
return 217
case metrics.MetricSourceOpenTelemetryCollectorElasticsearchReceiver:
return 218
case metrics.MetricSourceOpenTelemetryCollectorExpvarReceiver:
return 219
case metrics.MetricSourceOpenTelemetryCollectorFilestatsReceiver:
return 220
case metrics.MetricSourceOpenTelemetryCollectorFlinkmetricsReceiver:
return 221
case metrics.MetricSourceOpenTelemetryCollectorGitproviderReceiver:
return 222
case metrics.MetricSourceOpenTelemetryCollectorHaproxyReceiver:
return 223
case metrics.MetricSourceOpenTelemetryCollectorHostmetricsReceiver:
return 224
case metrics.MetricSourceOpenTelemetryCollectorHttpcheckReceiver:
return 225
case metrics.MetricSourceOpenTelemetryCollectorIisReceiver:
return 226
case metrics.MetricSourceOpenTelemetryCollectorK8sclusterReceiver:
return 227
case metrics.MetricSourceOpenTelemetryCollectorKafkametricsReceiver:
return 228
case metrics.MetricSourceOpenTelemetryCollectorKubeletstatsReceiver:
return 229
case metrics.MetricSourceOpenTelemetryCollectorMemcachedReceiver:
return 230
case metrics.MetricSourceOpenTelemetryCollectorMongodbatlasReceiver:
return 231
case metrics.MetricSourceOpenTelemetryCollectorMongodbReceiver:
return 232
case metrics.MetricSourceOpenTelemetryCollectorMysqlReceiver:
return 233
case metrics.MetricSourceOpenTelemetryCollectorNginxReceiver:
return 234
case metrics.MetricSourceOpenTelemetryCollectorNsxtReceiver:
return 235
case metrics.MetricSourceOpenTelemetryCollectorOracledbReceiver:
return 236
case metrics.MetricSourceOpenTelemetryCollectorPostgresqlReceiver:
return 237
case metrics.MetricSourceOpenTelemetryCollectorPrometheusReceiver:
return 238
case metrics.MetricSourceOpenTelemetryCollectorRabbitmqReceiver:
return 239
case metrics.MetricSourceOpenTelemetryCollectorRedisReceiver:
return 240
case metrics.MetricSourceOpenTelemetryCollectorRiakReceiver:
return 241
case metrics.MetricSourceOpenTelemetryCollectorSaphanaReceiver:
return 242
case metrics.MetricSourceOpenTelemetryCollectorSnmpReceiver:
return 243
case metrics.MetricSourceOpenTelemetryCollectorSnowflakeReceiver:
return 244
case metrics.MetricSourceOpenTelemetryCollectorSplunkenterpriseReceiver:
return 245
case metrics.MetricSourceOpenTelemetryCollectorSqlserverReceiver:
return 246
case metrics.MetricSourceOpenTelemetryCollectorSshcheckReceiver:
return 247
case metrics.MetricSourceOpenTelemetryCollectorStatsdReceiver:
return 248
case metrics.MetricSourceOpenTelemetryCollectorVcenterReceiver:
return 249
case metrics.MetricSourceOpenTelemetryCollectorZookeeperReceiver:
return 250
case metrics.MetricSourceOpenTelemetryCollectorActiveDirectorydsReceiver:
return 251
case metrics.MetricSourceOpenTelemetryCollectorAerospikeReceiver:
return 252
case metrics.MetricSourceOpenTelemetryCollectorApacheReceiver:
return 253
case metrics.MetricSourceOpenTelemetryCollectorApachesparkReceiver:
return 254
case metrics.MetricSourceOpenTelemetryCollectorAzuremonitorReceiver:
return 255
case metrics.MetricSourceOpenTelemetryCollectorBigipReceiver:
return 256
case metrics.MetricSourceOpenTelemetryCollectorChronyReceiver:
return 257
case metrics.MetricSourceOpenTelemetryCollectorCouchdbReceiver:
return 258

case metrics.MetricSourceArgoRollouts:
return 314
case metrics.MetricSourceArgoWorkflows:
Expand Down
6 changes: 1 addition & 5 deletions pkg/serializer/internal/metrics/sketch_series_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,6 @@ func (pb *payloadsBuilder) marshal(ss *metrics.SketchSeries) error {
const sketchMetadataOriginOriginService = 6
// |----| 'Origin' message
// |-----------| 'origin_service' field index
const serieMetadataOriginOriginProductAgentType = 10
// |----| 'Origin' message
// |-----------| 'OriginProduct' enum
// |-------| 'Agent' enum value

pb.buf.Reset()
err := pb.ps.Embedded(payloadSketches, func(ps *molecule.ProtoStream) error {
Expand Down Expand Up @@ -336,7 +332,7 @@ func (pb *payloadsBuilder) marshal(ss *metrics.SketchSeries) error {
return err
}
}
err = ps.Int32(sketchMetadataOriginOriginProduct, serieMetadataOriginOriginProductAgentType)
err = ps.Int32(sketchMetadataOriginOriginProduct, metricSourceToOriginProduct(ss.Source))
if err != nil {
return err
}
Expand Down

0 comments on commit a9985e3

Please sign in to comment.