Skip to content

Commit

Permalink
Fix commented code
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonardo Parente committed Apr 12, 2023
1 parent f4dd0a8 commit 6f4a7e7
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions sinker/otel/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/orb-community/orb/sinker/otel/orbreceiver"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config/configtelemetry"
"go.opentelemetry.io/collector/confmap"
"go.opentelemetry.io/collector/exporter"
"go.opentelemetry.io/collector/processor"
"go.opentelemetry.io/collector/receiver"
Expand Down Expand Up @@ -56,19 +57,23 @@ func StartOtelComponents(ctx context.Context, bridgeService *bridgeservice.Sinke
transformCtx := context.WithValue(otelContext, "component", "transformprocessor")
log.Info("start to create component", zap.Any("component", transformCtx.Value("component")))
transformCfg := transformFactory.CreateDefaultConfig().(*transformprocessor.Config)
// transformCfg.MetricStatements = []transformprocessor.ContextStatements{
// {Statements: []string{
// `set(attributes["agent-name"], resource.attributes["agent_name"])`,
// `set(attributes["agent-tags"], resource.attributes["agent_tags"])`,
// `set(attributes["orb-tags"], resource.attributes["orb_tags"])`,
// `set(attributes["agent-groups"], resource.attributes["agent_groups"])`,
// `set(attributes["agent-ownerID"], resource.attributes["agent_ownerID"])`,
// `set(attributes["policy-id"], resource.attributes["policy_id"])`,
// `set(attributes["policy-name"], resource.attributes["policy_name"])`,
// `set(attributes["sink-id"], resource.attributes["sink_id"])`,
// `set(attributes["format"], "otlp")`,
// }},
// }
cmap := map[string]interface{}{
"metric_statements": map[string]interface{}{
"context": "resource",
"statements": []string{
`set(attributes["agent-name"], resource.attributes["agent_name"])`,
`set(attributes["agent-tags"], resource.attributes["agent_tags"])`,
`set(attributes["orb-tags"], resource.attributes["orb_tags"])`,
`set(attributes["agent-groups"], resource.attributes["agent_groups"])`,
`set(attributes["agent-ownerID"], resource.attributes["agent_ownerID"])`,
`set(attributes["policy-id"], resource.attributes["policy_id"])`,
`set(attributes["policy-name"], resource.attributes["policy_name"])`,
`set(attributes["sink-id"], resource.attributes["sink_id"])`,
},
},
}
cconf := confmap.NewFromStringMap(cmap)
component.UnmarshalConfig(cconf, transformCfg)
transformSet := processor.CreateSettings{
TelemetrySettings: component.TelemetrySettings{
Logger: logger,
Expand Down

0 comments on commit 6f4a7e7

Please sign in to comment.