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

cassandra exporter keyspace check and dynamic timeout #27681

Merged
merged 20 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
3aec13b
cassandra keyspace check and dynamic timeout
emreyalvac Oct 16, 2023
ad3a6fe
type conversion fixed
emreyalvac Oct 28, 2023
822a854
type conversion fixed
emreyalvac Oct 28, 2023
769ebdb
default timeout for cassandra
emreyalvac Oct 28, 2023
b67e39b
review fixes
emreyalvac Oct 31, 2023
c36eddd
Merge branch 'main' into cassandra-exists-and-timeout
emreyalvac Oct 31, 2023
8a5afd7
Update exporter/cassandraexporter/exporter_logs.go
emreyalvac Nov 15, 2023
2852b62
Update exporter/cassandraexporter/example/otel-collector-config.yml
emreyalvac Nov 15, 2023
3b3f10d
Update exporter/cassandraexporter/README.md
emreyalvac Nov 15, 2023
1ce47af
Update exporter/cassandraexporter/factory.go
emreyalvac Nov 15, 2023
7a51cf7
Update exporter/cassandraexporter/testdata/config.yaml
emreyalvac Nov 15, 2023
d7f7cf5
Merge branch 'main' into cassandra-exists-and-timeout
emreyalvac Nov 15, 2023
10283aa
Merge branch 'main' into cassandra-exists-and-timeout
emreyalvac Nov 19, 2023
a91b00f
Merge branch 'main' into cassandra-exists-and-timeout
emreyalvac Nov 21, 2023
f6892af
import and some style fixes
emreyalvac Nov 21, 2023
9367f96
Merge branch 'main' into cassandra-exists-and-timeout
emreyalvac Nov 22, 2023
66c4f9b
Merge branch 'main' into cassandra-exists-and-timeout
fatsheep9146 Nov 23, 2023
213de5f
Merge branch 'main' into cassandra-exists-and-timeout
emreyalvac Nov 23, 2023
2f06fd8
Merge branch 'main' into cassandra-exists-and-timeout
Nov 28, 2023
330168e
Merge branch 'main' into cassandra-exists-and-timeout
emreyalvac Nov 28, 2023
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
27 changes: 27 additions & 0 deletions .chloggen/cassandra-exists-and-timeout.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: 'bug_fix'

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: 'cassandraexporter'

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: "Exist check for keyspace and dynamic timeout"

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [27633]

# (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:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: [user, api]
4 changes: 3 additions & 1 deletion exporter/cassandraexporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ 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)
- `port` (default = 9042) The Cassandra server Port
- `port` (default = 9042) The Cassandra server Port
atoulme marked this conversation as resolved.
Show resolved Hide resolved
- `timeout` (default = 10s) The Cassandra server connection timeout
atoulme marked this conversation as resolved.
Show resolved Hide resolved
- `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
Expand All @@ -32,6 +33,7 @@ exporters:
cassandra:
dsn: 127.0.0.1
port: 9042
timeout: 10s
keyspace: "otel"
trace_table: "otel_spans"
replication:
Expand Down
16 changes: 9 additions & 7 deletions exporter/cassandraexporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@
// SPDX-License-Identifier: Apache-2.0

package cassandraexporter // import "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/cassandraexporter"
import "time"

type Config struct {
DSN string `mapstructure:"dsn"`
Port int `mapstructure:"port"`
Keyspace string `mapstructure:"keyspace"`
TraceTable string `mapstructure:"trace_table"`
LogsTable string `mapstructure:"logs_table"`
Replication Replication `mapstructure:"replication"`
Compression Compression `mapstructure:"compression"`
DSN string `mapstructure:"dsn"`
Port int `mapstructure:"port"`
Timeout time.Duration `mapstructure:"timeout"`
Keyspace string `mapstructure:"keyspace"`
TraceTable string `mapstructure:"trace_table"`
LogsTable string `mapstructure:"logs_table"`
Replication Replication `mapstructure:"replication"`
Compression Compression `mapstructure:"compression"`
}

type Replication struct {
Expand Down
2 changes: 1 addition & 1 deletion exporter/cassandraexporter/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package cassandraexporter // import "github.com/open-telemetry/opentelemetry-col

const (
// language=SQL
createDatabaseSQL = `CREATE KEYSPACE %s WITH REPLICATION = { 'class' : '%s', 'replication_factor' : %d };`
createDatabaseSQL = `CREATE KEYSPACE IF NOT EXISTS %s WITH REPLICATION = { 'class' : '%s', 'replication_factor' : %d };`
// language=SQL
createEventTypeSQL = `CREATE TYPE IF NOT EXISTS %s.Events (Timestamp Date, Name text, Attributes map<text, text>);`
// language=SQL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ receivers:
exporters:
cassandra:
dsn: 127.0.0.1
port: 9042
timeout: 10s
keyspace: "otel"
trace_table: "otel_spans"
logs_table: "otel_logs"
Expand All @@ -14,7 +16,6 @@ exporters:
replication_factor: 1
compression:
algorithm: "ZstdCompressor"

service:
pipelines:
traces:
Expand Down
4 changes: 4 additions & 0 deletions exporter/cassandraexporter/exporter_logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ func newLogsExporter(logger *zap.Logger, cfg *Config) (*logsExporter, error) {
cluster.Consistency = gocql.Quorum
cluster.Port = cfg.Port

cluster.Timeout = cfg.Timeout
atoulme marked this conversation as resolved.
Show resolved Hide resolved

if err != nil {
return nil, err
}
Expand All @@ -43,6 +45,8 @@ func initializeLogKernel(cfg *Config) error {
cluster.Consistency = gocql.Quorum
cluster.Port = cfg.Port

cluster.Timeout = cfg.Timeout * time.Second

session, err := cluster.CreateSession()
if err != nil {
return err
Expand Down
4 changes: 4 additions & 0 deletions exporter/cassandraexporter/exporter_traces.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ func newTracesExporter(logger *zap.Logger, cfg *Config) (*tracesExporter, error)
cluster.Consistency = gocql.Quorum
cluster.Port = cfg.Port

cluster.Timeout = cfg.Timeout * time.Second

if err != nil {
return nil, err
}
Expand All @@ -42,6 +44,8 @@ func initializeTraceKernel(cfg *Config) error {
cluster.Consistency = gocql.Quorum
cluster.Port = cfg.Port

cluster.Timeout = cfg.Timeout * time.Second

session, err := cluster.CreateSession()
if err != nil {
return err
Expand Down
1 change: 1 addition & 0 deletions exporter/cassandraexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
return &Config{
DSN: "127.0.0.1",
Port: 9042,
Timeout: 10 * time.Second,

Check failure on line 29 in exporter/cassandraexporter/factory.go

View workflow job for this annotation

GitHub Actions / govulncheck (exporter)

undefined: time
Keyspace: "otel",
TraceTable: "otel_spans",
LogsTable: "otel_logs",
Expand Down
1 change: 1 addition & 0 deletions exporter/cassandraexporter/testdata/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ cassandra:
dsn: 127.0.0.1
keyspace: "otel"
trace_table: "otel_spans"
timeout: 10s
logs_table: "otel_logs"
replication:
class: "SimpleStrategy"
Expand Down
Loading