Skip to content

Commit

Permalink
fix metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
jpinsonneau committed Jul 10, 2024
1 parent efdb0d4 commit 9c9c293
Showing 1 changed file with 24 additions and 18 deletions.
42 changes: 24 additions & 18 deletions controllers/flp/flp_pipeline_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -493,28 +493,34 @@ func (b *PipelineBuilder) createOpenTelemetryStage(name string, spec *flowslates
Headers: spec.Headers,
}

// otel logs config
if spec.Logs.Enable != nil && *spec.Logs.Enable {
logsEnabled := spec.Logs.Enable != nil && *spec.Logs.Enable
metricsEnabled := spec.Metrics.Enable != nil && *spec.Metrics.Enable

if logsEnabled || metricsEnabled {
// add transform stage
transformStage := fromStage.TransformGeneric(fmt.Sprintf("%s-transform", name), helper.GetOtelTransformConfig(spec.FieldsMapping))
// add encode stage(s)
transformStage.EncodeOtelLogs(fmt.Sprintf("%s-logs", name), api.EncodeOtlpLogs{
OtlpConnectionInfo: &conn,
})
}

// otel metrics config
if spec.Metrics.Enable != nil && *spec.Metrics.Enable {
fromStage.EncodeOtelMetrics(fmt.Sprintf("%s-metrics", name), api.EncodeOtlpMetrics{
OtlpConnectionInfo: &conn,
Prefix: "netobserv",
Metrics: helper.GetOtelMetrics(flpMetrics),
PushTimeInterval: api.Duration{Duration: spec.Metrics.PushTimeInterval.Duration},
ExpiryTime: api.Duration{Duration: 2 * time.Minute},
})
}
// otel logs config
if logsEnabled {
// add encode stage(s)
transformStage.EncodeOtelLogs(fmt.Sprintf("%s-logs", name), api.EncodeOtlpLogs{
OtlpConnectionInfo: &conn,
})
}

// otel metrics config
if metricsEnabled {
transformStage.EncodeOtelMetrics(fmt.Sprintf("%s-metrics", name), api.EncodeOtlpMetrics{
OtlpConnectionInfo: &conn,
Prefix: "netobserv",
Metrics: helper.GetOtelMetrics(flpMetrics),
PushTimeInterval: api.Duration{Duration: spec.Metrics.PushTimeInterval.Duration},
ExpiryTime: api.Duration{Duration: 2 * time.Minute},
})
}

// TODO: implement api.EncodeOtlpTraces
// TODO: implement api.EncodeOtlpTraces
}
}

func getOtelConnType(connType string) string {
Expand Down

0 comments on commit 9c9c293

Please sign in to comment.