Skip to content
Open
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
b066750
Using otlphttp exporter for self metrics
rafaelwestphal Oct 15, 2025
3e29132
Adding the necessary transformers for agent metric
rafaelwestphal Oct 16, 2025
0969945
Removing extensions when unnecessar
rafaelwestphal Oct 16, 2025
06ae486
Include selfmetrics
rafaelwestphal Oct 17, 2025
6b8674d
Fixing golden
rafaelwestphal Oct 17, 2025
8901822
Merge branch 'master' into westphalrafael-agent-otlp
rafaelwestphal Oct 17, 2025
486f335
Merge branch 'master' into westphalrafael-agent-otlp
rafaelwestphal Oct 21, 2025
2ca0535
MErging file
rafaelwestphal Oct 22, 2025
68f9c4d
Merge branch 'master' into westphalrafael-agent-otlp
rafaelwestphal Oct 22, 2025
27f1487
Fix lint
rafaelwestphal Oct 22, 2025
7c6ab48
Refactoring how to run featureflag tests
rafaelwestphal Oct 23, 2025
0203366
Merge branch 'master' into westphalrafael-agent-otlp
rafaelwestphal Oct 31, 2025
fb747cc
Merge branch 'master' into westphalrafael-agent-otlp
rafaelwestphal Nov 4, 2025
3d60aa6
Merge branch 'master' into westphalrafael-agent-otlp
rafaelwestphal Nov 5, 2025
75b3426
Resuing some processor
rafaelwestphal Nov 5, 2025
dad0225
Refactoring code and removing comments
rafaelwestphal Nov 12, 2025
d06c53e
Merge branch 'master' into westphalrafael-agent-otlp
rafaelwestphal Nov 12, 2025
4b1d06d
Merge branch 'master' into westphalrafael-agent-otlp
rafaelwestphal Nov 12, 2025
958fb37
Copying host.id to instance_id to bypass bug 459468648
rafaelwestphal Nov 12, 2025
49d5d56
upDating golden
rafaelwestphal Nov 13, 2025
0f1b0d2
Fixing tranformation test
rafaelwestphal Nov 13, 2025
72f0623
Merge branch 'master' into westphalrafael-agent-otlp
rafaelwestphal Nov 19, 2025
193dd21
Adding system specific changes
rafaelwestphal Nov 19, 2025
edfe554
formating
rafaelwestphal Nov 19, 2025
db9427a
Readjust when the change type from dobule to int
rafaelwestphal Nov 27, 2025
a87cb54
Merge branch 'master' into westphalrafael-agent-otlp
rafaelwestphal Nov 27, 2025
87f07ee
update golden
rafaelwestphal Nov 27, 2025
d85b391
Merge branch 'master' into westphalrafael-agent-otlp
rafaelwestphal Nov 28, 2025
aab9b17
Fixing merge
rafaelwestphal Nov 28, 2025
ecbc31f
Removing ProjectName since we are obatinng inside the aux funt
rafaelwestphal Nov 28, 2025
939da8e
Removing unnecessary ProjectNaME
rafaelwestphal Dec 1, 2025
9f32772
Merge branch 'master' into westphalrafael-agent-otlp
rafaelwestphal Dec 1, 2025
460ca97
update golden
rafaelwestphal Dec 1, 2025
1cf2746
Merge branch 'master' into westphalrafael-agent-otlp
rafaelwestphal Dec 5, 2025
06a6d3f
Reverting change to scaler transformation
rafaelwestphal Dec 5, 2025
765ab8d
Add the other changes
rafaelwestphal Dec 5, 2025
3b0a878
Reveting bad scalar changew
rafaelwestphal Dec 5, 2025
0d45cb4
Adding metricstarttime when using otlphtrp
rafaelwestphal Dec 8, 2025
d4224ac
Merge branch 'master' into westphalrafael-agent-otlp
rafaelwestphal Dec 8, 2025
936ae3d
Adding function
rafaelwestphal Dec 8, 2025
d387e0a
Added metricstarttime exporter to the end of the pipelines
rafaelwestphal Dec 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/active_directory_ds.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (r MetricsReceiverActiveDirectoryDS) Pipelines(ctx context.Context) ([]otel
),
otel.MetricsRemoveServiceAttributes(),
}},
}, ctx)}, nil
}, ctx, false)}, nil
}

func init() {
Expand Down
2 changes: 1 addition & 1 deletion apps/aerospike.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (r MetricsReceiverAerospike) Pipelines(ctx context.Context) ([]otel.Receive
),
otel.MetricsRemoveServiceAttributes(),
}},
}, ctx)}, nil
}, ctx, false)}, nil
}

func init() {
Expand Down
2 changes: 1 addition & 1 deletion apps/apache.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (r MetricsReceiverApache) Pipelines(ctx context.Context) ([]otel.ReceiverPi
),
otel.MetricsRemoveServiceAttributes(),
}},
}, ctx)}, nil
}, ctx, false)}, nil
}

func init() {
Expand Down
2 changes: 1 addition & 1 deletion apps/couchbase.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func (r MetricsReceiverCouchbase) Pipelines(ctx context.Context) ([]otel.Receive
),
otel.MetricsRemoveServiceAttributes(),
}},
}, ctx)}, nil
}, ctx, false)}, nil
}

type couchbaseMetric struct {
Expand Down
2 changes: 1 addition & 1 deletion apps/couchdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (r MetricsReceiverCouchdb) Pipelines(ctx context.Context) ([]otel.ReceiverP
),
otel.MetricsRemoveServiceAttributes(),
}},
}, ctx)}, nil
}, ctx, false)}, nil
}

func init() {
Expand Down
2 changes: 1 addition & 1 deletion apps/dcgm.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func (r MetricsReceiverDcgm) Pipelines(ctx context.Context) ([]otel.ReceiverPipe
),
},
},
}, ctx)}, nil
}, ctx, false)}, nil
}

func init() {
Expand Down
2 changes: 1 addition & 1 deletion apps/elasticsearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (r MetricsReceiverElasticsearch) Pipelines(ctx context.Context) ([]otel.Rec
),
otel.MetricsRemoveServiceAttributes(),
}},
}, ctx)}, nil
}, ctx, false)}, nil
}

func (r MetricsReceiverElasticsearch) skipJVMMetricsConfig(metricsConfig map[string]interface{}) {
Expand Down
2 changes: 1 addition & 1 deletion apps/flink.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (r MetricsReceiverFlink) Pipelines(ctx context.Context) ([]otel.ReceiverPip
),
otel.MetricsRemoveServiceAttributes(),
}},
}, ctx)}, nil
}, ctx, false)}, nil
}

func init() {
Expand Down
4 changes: 2 additions & 2 deletions apps/iis.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (r MetricsReceiverIis) Pipelines(ctx context.Context) ([]otel.ReceiverPipel
),
otel.NormalizeSums(),
}},
}, ctx)}, nil
}, ctx, false)}, nil
}

// Return version 1 if version is anything other than 2
Expand Down Expand Up @@ -144,7 +144,7 @@ func (r MetricsReceiverIis) Pipelines(ctx context.Context) ([]otel.ReceiverPipel
otel.SetScopeVersion("1.0"),
),
}},
}, ctx)}, nil
}, ctx, false)}, nil
}

func init() {
Expand Down
2 changes: 1 addition & 1 deletion apps/memcached.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (r MetricsReceiverMemcached) Pipelines(ctx context.Context) ([]otel.Receive
),
otel.MetricsRemoveServiceAttributes(),
}},
}, ctx)}, nil
}, ctx, false)}, nil
}

func init() {
Expand Down
2 changes: 1 addition & 1 deletion apps/mongodb.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (r MetricsReceiverMongoDB) Pipelines(ctx context.Context) ([]otel.ReceiverP
),
otel.MetricsRemoveServiceAttributes(),
}},
}, ctx)}, nil
}, ctx, false)}, nil
}

func init() {
Expand Down
4 changes: 2 additions & 2 deletions apps/mssql.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (m MetricsReceiverMssql) Pipelines(ctx context.Context) ([]otel.ReceiverPip
otel.MetricsRemoveServiceAttributes(),
otel.NormalizeSums(),
}},
}, ctx)}, nil
}, ctx, false)}, nil
}

return []otel.ReceiverPipeline{confgenerator.ConvertToOtlpExporter(otel.ReceiverPipeline{
Expand Down Expand Up @@ -108,7 +108,7 @@ func (m MetricsReceiverMssql) Pipelines(ctx context.Context) ([]otel.ReceiverPip
otel.SetScopeVersion("1.0"),
),
}},
}, ctx)}, nil
}, ctx, false)}, nil
}

func init() {
Expand Down
2 changes: 1 addition & 1 deletion apps/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (r MetricsReceiverMySql) Pipelines(ctx context.Context) ([]otel.ReceiverPip
),
otel.MetricsRemoveServiceAttributes(),
}},
}, ctx)}, nil
}, ctx, false)}, nil
}

func init() {
Expand Down
2 changes: 1 addition & 1 deletion apps/nginx.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (r MetricsReceiverNginx) Pipelines(ctx context.Context) ([]otel.ReceiverPip
otel.SetScopeVersion("1.0"),
),
otel.MetricsRemoveServiceAttributes(),
}}}, ctx)}, nil
}}}, ctx, false)}, nil
}

func init() {
Expand Down
2 changes: 1 addition & 1 deletion apps/oracledb.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (r MetricsReceiverOracleDB) Pipelines(ctx context.Context) ([]otel.Receiver
),
otel.MetricsRemoveServiceAttributes(),
}},
}, ctx)}, nil
}, ctx, false)}, nil
}

var oracleQueries = []sqlReceiverQuery{
Expand Down
2 changes: 1 addition & 1 deletion apps/postgresql.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (r MetricsReceiverPostgresql) Pipelines(ctx context.Context) ([]otel.Receiv
),
otel.MetricsRemoveServiceAttributes(),
}},
}, ctx)}, nil
}, ctx, false)}, nil
}

func init() {
Expand Down
2 changes: 1 addition & 1 deletion apps/rabbitmq.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func (r MetricsReceiverRabbitmq) Pipelines(ctx context.Context) ([]otel.Receiver
),
otel.MetricsRemoveServiceAttributes(),
}},
}, ctx)}, nil
}, ctx, false)}, nil
}

func init() {
Expand Down
2 changes: 1 addition & 1 deletion apps/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (r MetricsReceiverRedis) Pipelines(ctx context.Context) ([]otel.ReceiverPip
),
otel.MetricsRemoveServiceAttributes(),
}},
}, ctx)}, nil
}, ctx, false)}, nil
}

func init() {
Expand Down
2 changes: 1 addition & 1 deletion apps/saphana.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func (s MetricsReceiverSapHana) Pipelines(ctx context.Context) ([]otel.ReceiverP
),
otel.MetricsRemoveServiceAttributes(),
}},
}, ctx)}, nil
}, ctx, false)}, nil
}

func init() {
Expand Down
2 changes: 1 addition & 1 deletion apps/varnish.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (r MetricsReceiverVarnish) Pipelines(ctx context.Context) ([]otel.ReceiverP
),
otel.MetricsRemoveServiceAttributes(),
}},
}, ctx)}, nil
}, ctx, false)}, nil
}

func init() {
Expand Down
2 changes: 1 addition & 1 deletion apps/vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func (r MetricsReceiverVault) Pipelines(ctx context.Context) ([]otel.ReceiverPip
),
otel.MetricsRemoveServiceAttributes(),
}},
}, ctx)}, nil
}, ctx, false)}, nil
}

type metricTransformer struct {
Expand Down
2 changes: 1 addition & 1 deletion apps/zookeeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (r MetricsReceiverZookeeper) Pipelines(ctx context.Context) ([]otel.Receive
),
otel.MetricsRemoveServiceAttributes(),
}},
}, ctx)}, nil
}, ctx, false)}, nil
}

type LoggingProcessorMacroZookeeperGeneral struct{}
Expand Down
24 changes: 13 additions & 11 deletions confgenerator/agentmetrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package confgenerator

import (
"context"
"fmt"
"path/filepath"
"time"
Expand All @@ -33,6 +34,7 @@ type AgentSelfMetrics struct {
OtelPort int
OtelRuntimeDir string
OtelLogging bool
ProjectName string
}

// Following reference : https://github.com/googleapis/googleapis/blob/master/google/rpc/code.proto
Expand All @@ -56,9 +58,9 @@ var grpcToHTTPStatus = map[string]string{
"DEADLINE_EXCEEDED": "504",
}

func (r AgentSelfMetrics) AddSelfMetricsPipelines(receiverPipelines map[string]otel.ReceiverPipeline, pipelines map[string]otel.Pipeline) {
func (r AgentSelfMetrics) AddSelfMetricsPipelines(receiverPipelines map[string]otel.ReceiverPipeline, pipelines map[string]otel.Pipeline, ctx context.Context) {
// Receiver pipelines names should have 1 underscore to avoid collision with user configurations.
receiverPipelines["agent_prometheus"] = r.PrometheusMetricsPipeline()
receiverPipelines["agent_prometheus"] = r.PrometheusMetricsPipeline(ctx)

// Pipeline names should have no underscores to avoid collision with user configurations.
pipelines["otel"] = otel.Pipeline{
Expand All @@ -79,15 +81,15 @@ func (r AgentSelfMetrics) AddSelfMetricsPipelines(receiverPipelines map[string]o
Processors: r.LoggingMetricsPipelineProcessors(),
}

receiverPipelines["ops_agent"] = r.OpsAgentPipeline()
receiverPipelines["ops_agent"] = r.OpsAgentPipeline(ctx)
pipelines["opsagent"] = otel.Pipeline{
Type: "metrics",
ReceiverPipelineName: "ops_agent",
}
}

func (r AgentSelfMetrics) PrometheusMetricsPipeline() otel.ReceiverPipeline {
return otel.ReceiverPipeline{
func (r AgentSelfMetrics) PrometheusMetricsPipeline(ctx context.Context) otel.ReceiverPipeline {
return ConvertToOtlpExporter(otel.ReceiverPipeline{
Receiver: otel.Component{
Type: "prometheus",
Config: map[string]interface{}{
Expand Down Expand Up @@ -128,7 +130,7 @@ func (r AgentSelfMetrics) PrometheusMetricsPipeline() otel.ReceiverPipeline {
),
},
},
}
}, ctx, true)
}

func (r AgentSelfMetrics) OtelPipelineProcessors() []otel.Component {
Expand Down Expand Up @@ -303,18 +305,18 @@ func (r AgentSelfMetrics) LoggingMetricsPipelineProcessors() []otel.Component {
}
}

func (r AgentSelfMetrics) OpsAgentPipeline() otel.ReceiverPipeline {
receiver_config := map[string]any{
func (r AgentSelfMetrics) OpsAgentPipeline(ctx context.Context) otel.ReceiverPipeline {
receiverConfig := map[string]any{
"include": []string{
filepath.Join(r.OtelRuntimeDir, "enabled_receivers_otlp.json"),
filepath.Join(r.OtelRuntimeDir, "feature_tracking_otlp.json")},
"replay_file": true,
"poll_interval": time.Duration(60 * time.Second).String(),
}
return otel.ReceiverPipeline{
return ConvertToOtlpExporter(otel.ReceiverPipeline{
Receiver: otel.Component{
Type: "otlpjsonfile",
Config: receiver_config,
Config: receiverConfig,
},
ExporterTypes: map[string]otel.ExporterType{
"metrics": otel.System,
Expand All @@ -324,7 +326,7 @@ func (r AgentSelfMetrics) OpsAgentPipeline() otel.ReceiverPipeline {
otel.Transform("metric", "datapoint", []ottl.Statement{"set(time, Now())"}),
},
},
}
}, ctx, true)
}

// intentionally not registered as a component because this is not created by users
32 changes: 21 additions & 11 deletions confgenerator/confgenerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,24 @@ func googleCloudExporter(userAgent string, instrumentationLabels bool, serviceRe
}
}

func ConvertToOtlpExporter(receiver otel.ReceiverPipeline, ctx context.Context) otel.ReceiverPipeline {
func ConvertToOtlpExporter(pipeline otel.ReceiverPipeline, ctx context.Context, systemMetric bool) otel.ReceiverPipeline {
expOtlpExporter := experimentsFromContext(ctx)["otlp_exporter"]
resource, _ := platform.FromContext(ctx).GetResource()
if !expOtlpExporter {
return receiver
return pipeline
}
_, err := receiver.ExporterTypes["metrics"]
_, err := pipeline.ExporterTypes["metrics"]
if !err {
return receiver
return pipeline
}
receiver.ExporterTypes["metrics"] = otel.OTLP
pipeline.ExporterTypes["metrics"] = otel.OTLP

receiver.Processors["metrics"] = append(receiver.Processors["metrics"], otel.GCPProjectID(resource.ProjectName()))
return receiver
pipeline.Processors["metrics"] = append(pipeline.Processors["metrics"], otel.GCPProjectID(resource.ProjectName()))
if systemMetric {
pipeline.Processors["metrics"] = append(pipeline.Processors["metrics"], otel.MetricStartTime())
pipeline.Processors["metrics"] = append(pipeline.Processors["metrics"], otel.MetricsRemoveInstrumentationLibraryLabelsAttributes())
}
return pipeline
}

func otlpExporter(userAgent string) otel.Component {
Expand Down Expand Up @@ -112,9 +116,15 @@ func (uc *UnifiedConfig) getOTelLogLevel() string {

func (uc *UnifiedConfig) GenerateOtelConfig(ctx context.Context, outDir string) (string, error) {
p := platform.FromContext(ctx)
resource, err := p.GetResource()
if err != nil {
log.Printf("can't get resource metadata: %v", err)
return "", nil
}
userAgent, _ := p.UserAgent("Google-Cloud-Ops-Agent-Metrics")
metricVersionLabel, _ := p.VersionLabel("google-cloud-ops-agent-metrics")
loggingVersionLabel, _ := p.VersionLabel("google-cloud-ops-agent-logging")
expOtlpExporter := experimentsFromContext(ctx)["otlp_exporter"]

receiverPipelines, pipelines, err := uc.generateOtelPipelines(ctx)
if err != nil {
Expand All @@ -128,12 +138,12 @@ func (uc *UnifiedConfig) GenerateOtelConfig(ctx context.Context, outDir string)
OtelPort: otel.MetricsPort,
OtelRuntimeDir: outDir,
OtelLogging: uc.Logging.Service.OTelLogging,
ProjectName: resource.ProjectName(),
}
agentSelfMetrics.AddSelfMetricsPipelines(receiverPipelines, pipelines)
agentSelfMetrics.AddSelfMetricsPipelines(receiverPipelines, pipelines, ctx)

exp_otlp_exporter := experimentsFromContext(ctx)["otlp_exporter"]
extensions := map[string]interface{}{}
if exp_otlp_exporter {
if expOtlpExporter {
extensions["googleclientauth"] = map[string]interface{}{}
}

Expand All @@ -148,7 +158,7 @@ func (uc *UnifiedConfig) GenerateOtelConfig(ctx context.Context, outDir string)
otel.GMP: googleManagedPrometheusExporter(userAgent),
otel.OTLP: otlpExporter(userAgent),
},
}.Generate(ctx, exp_otlp_exporter)
}.Generate(ctx, expOtlpExporter)
if err != nil {
return "", err
}
Expand Down
2 changes: 1 addition & 1 deletion confgenerator/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ func (m MetricsReceiverSharedJVM) ConfigurePipelines(targetSystem string, proces
Config: config,
},
Processors: map[string][]otel.Component{"metrics": processors},
}, ctx)}, nil
}, ctx, false)}, nil
}

type MetricsReceiverSharedCollectJVM struct {
Expand Down
7 changes: 7 additions & 0 deletions confgenerator/otel/processors.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,13 @@ func MetricsRemoveServiceAttributes() Component {
}
}

func MetricsRemoveInstrumentationLibraryLabelsAttributes() Component {
return TransformationMetrics(
SetScopeName(""),
SetScopeVersion(""),
)
}

func CopyHostIDToInstanceID() Component {
return Component{
Type: "transform",
Expand Down
Loading
Loading