-
Notifications
You must be signed in to change notification settings - Fork 487
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wire in otelcol.exporter.prometheus and fix problem with multiple tra…
…ce pipelines from load balancing Signed-off-by: erikbaranowski <[email protected]>
- Loading branch information
1 parent
50c7edd
commit 22b33a4
Showing
3 changed files
with
89 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
internal/converter/internal/staticconvert/internal/build/converter_prometheusexporter.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package build | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/grafana/agent/internal/component/otelcol/exporter/prometheus" | ||
"github.com/grafana/agent/internal/converter/diag" | ||
"github.com/grafana/agent/internal/converter/internal/common" | ||
"github.com/grafana/agent/internal/converter/internal/otelcolconvert" | ||
"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/prometheusexporter" | ||
"go.opentelemetry.io/collector/component" | ||
) | ||
|
||
func init() { | ||
converters = append(converters, prometheusExporterConverter{}) | ||
} | ||
|
||
type prometheusExporterConverter struct{} | ||
|
||
func (prometheusExporterConverter) Factory() component.Factory { | ||
return prometheusexporter.NewFactory() | ||
} | ||
|
||
func (prometheusExporterConverter) InputComponentName() string { | ||
return "otelcol.exporter.prometheus" | ||
} | ||
|
||
func (prometheusExporterConverter) ConvertAndAppend(state *otelcolconvert.State, id component.InstanceID, cfg component.Config) diag.Diagnostics { | ||
label := state.FlowComponentLabel() | ||
|
||
args := toPrometheusExporterConfig(state, id, cfg.(*prometheusexporter.Config), label) | ||
block := common.NewBlockWithOverride([]string{"otelcol", "exporter", "prometheus"}, label, args) | ||
|
||
var diags diag.Diagnostics | ||
diags.Add( | ||
diag.SeverityLevelInfo, | ||
fmt.Sprintf("Converted %s into %s", otelcolconvert.StringifyInstanceID(id), otelcolconvert.StringifyBlock(block)), | ||
) | ||
|
||
state.Body().AppendBlock(block) | ||
return diags | ||
} | ||
|
||
func toPrometheusExporterConfig(state *otelcolconvert.State, id component.InstanceID, cfg *prometheusexporter.Config, label string) *prometheus.Arguments { | ||
args := &prometheus.Arguments{} | ||
args.SetToDefault() | ||
args.GCFrequency = cfg.MetricExpiration | ||
args.AddMetricSuffixes = cfg.AddMetricSuffixes | ||
args.ResourceToTelemetryConversion = cfg.ResourceToTelemetrySettings.Enabled | ||
// TODO args.ForwardTo | ||
// IncludeTargetInfo: false, | ||
// IncludeScopeInfo: false, | ||
// IncludeScopeLabels: false, | ||
|
||
return args | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters