-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c7c8ffa
commit 957a208
Showing
22 changed files
with
978 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' | ||
change_type: new_component | ||
|
||
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) | ||
component: cassandra_exporter | ||
|
||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
note: Cassandra exporter implementation | ||
|
||
# One or more tracking issues related to the change | ||
issues: [ ] | ||
|
||
# (Optional) One or more lines of additional information to render under the primary note. | ||
# These lines will be padded with 2 spaces and then inserted directly into the document. | ||
# Use pipe (|) for multiline entries. | ||
subtext: |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,8 @@ | ||
include ../../Makefile.Common | ||
|
||
local-run-example: | ||
cd ../../ && GOOS=linux go build -o ./local/otelcontribcol ./cmd/otelcontribcol | ||
cd example && docker-compose up -d | ||
recreate-otel-collector: | ||
cd ../../ && GOOS=linux go build -o ./local/otelcontribcol ./cmd/otelcontribcol | ||
cd example && docker-compose up --build otelcollector |
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,46 @@ | ||
# Cassandra Exporter | ||
|
||
| Status | | | ||
|--------------------------|-----------| | ||
| Stability | [alpha] | | ||
| Supported pipeline types | traces | | ||
| Distributions | [contrib] | | ||
|
||
## Configuration options | ||
|
||
The following settings can be optionally configured: | ||
|
||
- `dsn` The Cassandra server DSN (Data Source Name), for example `127.0.0.1`. | ||
reference: [https://pkg.go.dev/github.com/gocql/gocql](https://pkg.go.dev/github.com/gocql/gocql) | ||
- `keyspace` (default = otel): The keyspace name. | ||
- `trace_table` (default = otel_spans): The table name for traces. | ||
- `replication` (default = class: SimpleStrategy, replication_factor: 1) The strategy of | ||
replication. https://cassandra.apache.org/doc/4.1/cassandra/architecture/dynamo.html#replication-strategy | ||
- `compression` (default = LZ4Compressor) https://cassandra.apache.org/doc/latest/cassandra/operating/compression.html | ||
|
||
## Example | ||
|
||
```yaml | ||
receivers: | ||
examplereceiver: | ||
processors: | ||
batch: | ||
timeout: 5s | ||
send_batch_size: 100000 | ||
exporters: | ||
cassandra: | ||
dsn: 127.0.0.1 | ||
keyspace: "otel" | ||
trace_table: "otel_spans" | ||
replication: | ||
class: "SimpleStrategy" | ||
replication_factor: 1 | ||
compression: | ||
algorithm: "ZstdCompressor" | ||
service: | ||
pipelines: | ||
logs: | ||
receivers: [ examplereceiver ] | ||
processors: [ batch ] | ||
exporters: [ cassandra ] | ||
``` |
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,18 @@ | ||
package cassandraexporter | ||
|
||
type Config struct { | ||
DSN string `mapstructure:"dsn"` | ||
Keyspace string `mapstructure:"keyspace"` | ||
TraceTable string `mapstructure:"trace_table"` | ||
Replication Replication `mapstructure:"replication"` | ||
Compression Compression `mapstructure:"compression"` | ||
} | ||
|
||
type Replication struct { | ||
Class string `mapstructure:"class"` | ||
ReplicationFactor int `mapstructure:"replication_factor"` | ||
} | ||
|
||
type Compression struct { | ||
Algorithm string `mapstructure:"algorithm"'` | ||
} |
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,69 @@ | ||
// Copyright 2020, OpenTelemetry Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package cassandraexporter | ||
|
||
import ( | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
"go.opentelemetry.io/collector/component" | ||
"go.opentelemetry.io/collector/confmap/confmaptest" | ||
"path/filepath" | ||
"testing" | ||
) | ||
|
||
const defaultDSN = "127.0.0.1" | ||
|
||
func TestLoadConfig(t *testing.T) { | ||
t.Parallel() | ||
|
||
cm, err := confmaptest.LoadConf(filepath.Join("testdata", "config.yaml")) | ||
require.NoError(t, err) | ||
|
||
defaultCfg := createDefaultConfig() | ||
defaultCfg.(*Config).DSN = defaultDSN | ||
|
||
tests := []struct { | ||
id component.ID | ||
expected component.Config | ||
}{ | ||
|
||
{ | ||
id: component.NewIDWithName(typeStr, ""), | ||
expected: defaultCfg, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.id.String(), func(t *testing.T) { | ||
factory := NewFactory() | ||
cfg := factory.CreateDefaultConfig() | ||
|
||
sub, err := cm.Sub(tt.id.String()) | ||
require.NoError(t, err) | ||
require.NoError(t, component.UnmarshalConfig(sub, cfg)) | ||
|
||
assert.NoError(t, component.ValidateConfig(cfg)) | ||
assert.Equal(t, tt.expected, cfg) | ||
}) | ||
} | ||
} | ||
|
||
func withDefaultConfig(fns ...func(*Config)) *Config { | ||
cfg := createDefaultConfig().(*Config) | ||
for _, fn := range fns { | ||
fn(cfg) | ||
} | ||
return cfg | ||
} |
21 changes: 21 additions & 0 deletions
21
exporter/cassandraexporter/example/otel-collector-config.yml
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,21 @@ | ||
receivers: | ||
otlp: | ||
protocols: | ||
grpc: | ||
endpoint: 0.0.0.0:4317 | ||
exporters: | ||
cassandra: | ||
dsn: 127.0.0.1 | ||
keyspace: "otel" | ||
trace_table: "otel_spans" | ||
replication: | ||
class: "SimpleStrategy" | ||
replication_factor: 1 | ||
compression: | ||
algorithm: "ZstdCompressor" | ||
|
||
service: | ||
pipelines: | ||
traces: | ||
receivers: [ otlp ] | ||
exporters: [ cassandra ] |
Oops, something went wrong.