Skip to content

Commit

Permalink
Merge branch 'main' into testbed/datarace
Browse files Browse the repository at this point in the history
  • Loading branch information
james-ryans committed Jan 16, 2024
2 parents 5c7a08f + 14d4394 commit 951bc5e
Show file tree
Hide file tree
Showing 37 changed files with 468 additions and 117 deletions.
20 changes: 20 additions & 0 deletions .chloggen/cassandraexporter-add-authorization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Use this changelog template to create an entry for release notes.
# If your change doesn't affect end users, such as a test fix or a tooling change,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.

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

# 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: added authorization by username and password

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

# (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:
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ connector/exceptionsconnector/ @open-telemetry/collect
connector/failoverconnector/ @open-telemetry/collector-contrib-approvers @djaglowski @fatsheep9146
connector/routingconnector/ @open-telemetry/collector-contrib-approvers @jpkrohling @mwear
connector/servicegraphconnector/ @open-telemetry/collector-contrib-approvers @jpkrohling @mapno
connector/spanmetricsconnector/ @open-telemetry/collector-contrib-approvers @albertteoh
connector/spanmetricsconnector/ @open-telemetry/collector-contrib-approvers @albertteoh @portertech

examples/demo/ @open-telemetry/collector-contrib-approvers @open-telemetry/collector-approvers

Expand Down
6 changes: 3 additions & 3 deletions cmd/configschema/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ require (
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v2 v2.2.1 // indirect
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.2.1 // indirect
github.com/Azure/azure-storage-queue-go v0.0.0-20230531184854-c06a8eff66fe // indirect
github.com/Azure/go-amqp v1.0.2 // indirect
github.com/Azure/go-amqp v1.0.3 // indirect
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
github.com/Azure/go-autorest/autorest v0.11.29 // indirect
github.com/Azure/go-autorest/autorest/adal v0.9.23 // indirect
Expand Down Expand Up @@ -246,7 +246,7 @@ require (
github.com/JohnCGriffin/overflow v0.0.0-20211019200055-46fa312c352c // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/ReneKroon/ttlcache/v2 v2.11.0 // indirect
github.com/SAP/go-hdb v1.7.1 // indirect
github.com/SAP/go-hdb v1.7.4 // indirect
github.com/SermoDigital/jose v0.9.2-0.20180104203859-803625baeddc // indirect
github.com/Showmax/go-fqdn v1.0.0 // indirect
github.com/aerospike/aerospike-client-go/v6 v6.13.0 // indirect
Expand Down Expand Up @@ -678,7 +678,7 @@ require (
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/crypto v0.18.0 // indirect
golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc // indirect
golang.org/x/exp v0.0.0-20240110193028-0dcbfd608b1e // indirect
golang.org/x/net v0.20.0 // indirect
golang.org/x/oauth2 v0.16.0 // indirect
golang.org/x/sync v0.5.0 // indirect
Expand Down
12 changes: 6 additions & 6 deletions cmd/configschema/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions cmd/otelcontribcol/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ require (
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.2.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.2.1 // indirect
github.com/Azure/azure-storage-queue-go v0.0.0-20230531184854-c06a8eff66fe // indirect
github.com/Azure/go-amqp v1.0.2 // indirect
github.com/Azure/go-amqp v1.0.3 // indirect
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
github.com/Azure/go-autorest/autorest v0.11.29 // indirect
github.com/Azure/go-autorest/autorest/adal v0.9.23 // indirect
Expand Down Expand Up @@ -295,7 +295,7 @@ require (
github.com/JohnCGriffin/overflow v0.0.0-20211019200055-46fa312c352c // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/ReneKroon/ttlcache/v2 v2.11.0 // indirect
github.com/SAP/go-hdb v1.7.1 // indirect
github.com/SAP/go-hdb v1.7.4 // indirect
github.com/SermoDigital/jose v0.9.2-0.20180104203859-803625baeddc // indirect
github.com/Showmax/go-fqdn v1.0.0 // indirect
github.com/aerospike/aerospike-client-go/v6 v6.13.0 // indirect
Expand Down Expand Up @@ -690,7 +690,7 @@ require (
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/crypto v0.18.0 // indirect
golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc // indirect
golang.org/x/exp v0.0.0-20240110193028-0dcbfd608b1e // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.20.0 // indirect
golang.org/x/oauth2 v0.16.0 // indirect
Expand Down
12 changes: 6 additions & 6 deletions cmd/otelcontribcol/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

121 changes: 121 additions & 0 deletions exporter/azuremonitorexporter/generated_component_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion exporter/azuremonitorexporter/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,10 @@ status:
beta: [traces, metrics, logs]
distributions: [contrib, observiq]
codeowners:
active: [pcwiese]
active: [pcwiese]

tests:
config:
connection_string: "InstrumentationKey=00000000-0000-0000-0000-000000000000;IngestionEndpoint=https://ingestion.azuremonitor.com/"
instrumentation_key: b1cd0778-85fc-4677-a3fa-79d3c23e0efd
expect_consumer_error: true
4 changes: 4 additions & 0 deletions exporter/cassandraexporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ The following settings can be optionally configured:
- `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
- `auth` (default = username: "", password: "") Authorization for the Cassandra.

## Example

Expand All @@ -41,4 +42,7 @@ exporters:
replication_factor: 1
compression:
algorithm: "ZstdCompressor"
auth:
username: "your-username"
password: "your-password"
```
12 changes: 11 additions & 1 deletion exporter/cassandraexporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
// SPDX-License-Identifier: Apache-2.0

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

"go.opentelemetry.io/collector/config/configopaque"
)

type Config struct {
DSN string `mapstructure:"dsn"`
Expand All @@ -13,6 +17,7 @@ type Config struct {
LogsTable string `mapstructure:"logs_table"`
Replication Replication `mapstructure:"replication"`
Compression Compression `mapstructure:"compression"`
Auth Auth `mapstructure:"auth"`
}

type Replication struct {
Expand All @@ -23,3 +28,8 @@ type Replication struct {
type Compression struct {
Algorithm string `mapstructure:"algorithm"`
}

type Auth struct {
UserName string `mapstructure:"username"`
Password configopaque.String `mapstructure:"password"`
}
32 changes: 29 additions & 3 deletions exporter/cassandraexporter/exporter_logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package cassandraexporter // import "github.com/open-telemetry/opentelemetry-col
import (
"context"
"encoding/json"
"errors"
"fmt"
"time"

Expand All @@ -24,13 +25,16 @@ type logsExporter struct {
}

func newLogsExporter(logger *zap.Logger, cfg *Config) (*logsExporter, error) {
cluster := gocql.NewCluster(cfg.DSN)
session, err := cluster.CreateSession()
cluster, err := newCluster(cfg)
if err != nil {
return nil, err
}
cluster.Keyspace = cfg.Keyspace
cluster.Consistency = gocql.Quorum
cluster.Port = cfg.Port
cluster.Timeout = cfg.Timeout

session, err := cluster.CreateSession()
if err != nil {
return nil, err
}
Expand All @@ -40,7 +44,10 @@ func newLogsExporter(logger *zap.Logger, cfg *Config) (*logsExporter, error) {

func initializeLogKernel(cfg *Config) error {
ctx := context.Background()
cluster := gocql.NewCluster(cfg.DSN)
cluster, err := newCluster(cfg)
if err != nil {
return err
}
cluster.Consistency = gocql.Quorum
cluster.Port = cfg.Port
cluster.Timeout = cfg.Timeout
Expand All @@ -64,6 +71,25 @@ func initializeLogKernel(cfg *Config) error {
return nil
}

func newCluster(cfg *Config) (*gocql.ClusterConfig, error) {
cluster := gocql.NewCluster(cfg.DSN)
if cfg.Auth.UserName != "" && cfg.Auth.Password == "" {
return nil, errors.New("empty auth.password")
}
if cfg.Auth.Password != "" && cfg.Auth.UserName == "" {
return nil, errors.New("empty auth.username")
}
if cfg.Auth.UserName != "" && cfg.Auth.Password != "" {
cluster.Authenticator = gocql.PasswordAuthenticator{
Username: cfg.Auth.UserName,
Password: string(cfg.Auth.Password),
}
}
cluster.Consistency = gocql.Quorum
cluster.Port = cfg.Port
return cluster, nil
}

func (e *logsExporter) Start(_ context.Context, _ component.Host) error {
initializeErr := initializeLogKernel(e.cfg)
return initializeErr
Expand Down
Loading

0 comments on commit 951bc5e

Please sign in to comment.