Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

port servicegraph processor code to connector #26092

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
41 changes: 41 additions & 0 deletions connector/servicegraphconnector/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package servicegraphconnector // import "github.com/open-telemetry/opentelemetry-collector-contrib/connector/servicegraphconnector"

import (
"time"
)

// Config defines the configuration options for servicegraphconnector.
type Config struct {

// LatencyHistogramBuckets is the list of durations representing latency histogram buckets.
// See defaultLatencyHistogramBucketsMs in connector.go for the default value.
LatencyHistogramBuckets []time.Duration `mapstructure:"latency_histogram_buckets"`

// Dimensions defines the list of additional dimensions on top of the provided:
// - client
// - server
// - failed
// - connection_type
// The dimensions will be fetched from the span's attributes. Examples of some conventionally used attributes:
// https://github.com/open-telemetry/opentelemetry-collector/blob/main/model/semconv/opentelemetry.go.
Dimensions []string `mapstructure:"dimensions"`

// Store contains the config for the in-memory store used to find requests between services by pairing spans.
Store StoreConfig `mapstructure:"store"`
// CacheLoop is the time to cleans the cache periodically.
CacheLoop time.Duration `mapstructure:"cache_loop"`
// StoreExpirationLoop is the time to expire old entries from the store periodically.
StoreExpirationLoop time.Duration `mapstructure:"store_expiration_loop"`
// VirtualNodePeerAttributes the list of attributes need to match, the higher the front, the higher the priority.
VirtualNodePeerAttributes []string `mapstructure:"virtual_node_peer_attributes"`
}

type StoreConfig struct {
// MaxItems is the maximum number of items to keep in the store.
MaxItems int `mapstructure:"max_items"`
// TTL is the time to live for items in the store.
TTL time.Duration `mapstructure:"ttl"`
}
45 changes: 45 additions & 0 deletions connector/servicegraphconnector/config_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package servicegraphconnector

import (
"path/filepath"
"testing"
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/otelcol/otelcoltest"

"github.com/open-telemetry/opentelemetry-collector-contrib/connector/servicegraphconnector/internal/metadata"
)

func TestLoadConfig(t *testing.T) {
// Prepare
factories, err := otelcoltest.NopFactories()
require.NoError(t, err)

factories.Connectors[metadata.Type] = NewFactory()

cfg, err := otelcoltest.LoadConfigAndValidate(filepath.Join("testdata", "service-graph-config.yaml"), factories)

// Verify
require.NoError(t, err)
require.NotNil(t, cfg)
assert.Equal(t,
&Config{
LatencyHistogramBuckets: []time.Duration{1, 2, 3, 4, 5},
Dimensions: []string{"dimension-1", "dimension-2"},
Store: StoreConfig{
TTL: time.Second,
MaxItems: 10,
},
CacheLoop: time.Minute,
StoreExpirationLoop: 2 * time.Second,
},
cfg.Connectors[component.NewID(metadata.Type)],
)

}
Loading