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

Coralogix processor first PR #33458

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
67bb24d
initial template, config, and first PR scripts
galrose Jun 10, 2024
6d7fe3b
fixed toolchain
galrose Jun 10, 2024
08ea9e1
Merge branch 'main' into coralogix-proccesor-first-pr
galrose Jun 10, 2024
35922ee
Update processor/coralogixprocessor/metadata.yaml
galrose Jun 11, 2024
b53a9f3
Update processor/coralogixprocessor/doc.go
galrose Jun 11, 2024
71a48f9
README.md fixes
galrose Jun 13, 2024
b5e1e6e
Merge remote-tracking branch 'origin/coralogix-proccesor-first-pr' in…
galrose Jun 13, 2024
70e11a5
fixed naming, removed code from span.go
galrose Jun 13, 2024
8bf11ae
Merge branch 'main' into coralogix-proccesor-first-pr
galrose Jun 13, 2024
7a03261
Update processor/coralogixprocessor/README.md
galrose Jun 16, 2024
5811865
removed max_cache_entries because of calculations, and other PR fixes
galrose Jun 16, 2024
361326b
Merge remote-tracking branch 'origin/coralogix-proccesor-first-pr' in…
galrose Jun 16, 2024
accbe6a
Merge branch 'main' into coralogix-proccesor-first-pr
galrose Jun 16, 2024
7a88b54
removed max_cache_entries from config.go
galrose Jun 16, 2024
2d82f0e
Merge branch 'main' into coralogix-proccesor-first-pr
galrose Jun 18, 2024
b53a35b
Update processor/coralogixprocessor/README.md
galrose Jun 18, 2024
a20b8a6
Merge branch 'main' into coralogix-proccesor-first-pr
galrose Jun 20, 2024
d68c182
added more information about disabling sampling
galrose Jun 20, 2024
bafd1ba
Changed createSettings to settings because its depricated
galrose Jun 20, 2024
d600988
Merge remote-tracking branch 'origin/coralogix-proccesor-first-pr' in…
galrose Jun 20, 2024
e95a743
add license
galrose Jun 20, 2024
2dd6c34
added enabled key to sampling
galrose Jun 23, 2024
f0db5df
Merge branch 'main' into coralogix-proccesor-first-pr
galrose Jun 25, 2024
19b5f13
added galrose to allowlist
galrose Jun 30, 2024
00e818d
Merge remote-tracking branch 'origin/coralogix-proccesor-first-pr' in…
galrose Jun 30, 2024
8b7623a
added go.sum
galrose Jun 30, 2024
7738f59
Merge branch 'main' into coralogix-proccesor-first-pr
galrose Jun 30, 2024
7a96743
Merge branch 'main' into coralogix-proccesor-first-pr
galrose Jul 4, 2024
2c7811a
added codeowners, removed unused imports and variables, updated otel …
galrose Jul 4, 2024
0fc97e8
ran some more scripts to pass workflow
galrose Jul 4, 2024
31c72c2
Merge branch 'main' into coralogix-proccesor-first-pr
galrose Jul 9, 2024
65f3e24
Update processor/coralogixprocessor/README.md
galrose Jul 10, 2024
fe14dfb
Update processor/coralogixprocessor/README.md
galrose Jul 10, 2024
0024f66
Update processor/coralogixprocessor/README.md
galrose Jul 10, 2024
3be5c7b
Update processor/coralogixprocessor/README.md
galrose Jul 10, 2024
9f4df26
Update processor/coralogixprocessor/config.go
galrose Jul 10, 2024
47329a2
added @crobert-1 to code owners as well
galrose Jul 10, 2024
26e7c79
fixed samplingConfig spelling mistake
galrose Jul 10, 2024
d17fd25
Merge branch 'main' into coralogix-proccesor-first-pr
galrose Jul 10, 2024
589e800
updated collector module versions
galrose Jul 10, 2024
3c5d145
updated modules
galrose Jul 10, 2024
af491a1
added members of my team as code owners as well
galrose Jul 11, 2024
a4166eb
Merge branch 'main' into coralogix-proccesor-first-pr
galrose Jul 23, 2024
9f3231d
updated package versions
galrose Jul 23, 2024
f547190
updated module versions
galrose Jul 23, 2024
7642ec9
fixed go.sum
galrose Jul 24, 2024
9901e7e
Merge branch 'main' into coralogix-proccesor-first-pr
atoulme Jul 30, 2024
f7b3b53
updated go modules
galrose Jul 30, 2024
4c6cbc2
Merge branch 'main' into coralogix-proccesor-first-pr
galrose Jul 31, 2024
827ba2a
updated go modules
galrose Jul 31, 2024
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/coralogix-proccesor-first-pr.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: new_component

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

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: creating new component for coralogix features

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

# (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: []
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ pkg/winperfcounters/ @open-teleme

processor/attributesprocessor/ @open-telemetry/collector-contrib-approvers @boostchicken
processor/cumulativetodeltaprocessor/ @open-telemetry/collector-contrib-approvers @TylerHelmuth
processor/coralogixprocessor/ @open-telemetry/collector-contrib-approvers @galrose @crobert-1 @eyalatz @roycald245
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link

@roycald245 roycald245 Aug 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do we fix this? Is this because we are missing in cmd/githubgen/allowlist.txt?

processor/deltatocumulativeprocessor/ @open-telemetry/collector-contrib-approvers @sh0rez @RichieSams @jpkrohling
processor/deltatorateprocessor/ @open-telemetry/collector-contrib-approvers @Aneurysm9
processor/filterprocessor/ @open-telemetry/collector-contrib-approvers @TylerHelmuth @boostchicken
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ body:
- pkg/translator/zipkin
- pkg/winperfcounters
- processor/attributes
- processor/coralogix
- processor/cumulativetodelta
- processor/deltatocumulative
- processor/deltatorate
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ body:
- pkg/translator/zipkin
- pkg/winperfcounters
- processor/attributes
- processor/coralogix
- processor/cumulativetodelta
- processor/deltatocumulative
- processor/deltatorate
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/other.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ body:
- pkg/translator/zipkin
- pkg/winperfcounters
- processor/attributes
- processor/coralogix
- processor/cumulativetodelta
- processor/deltatocumulative
- processor/deltatorate
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/unmaintained.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ body:
- pkg/translator/zipkin
- pkg/winperfcounters
- processor/attributes
- processor/coralogix
- processor/cumulativetodelta
- processor/deltatocumulative
- processor/deltatorate
Expand Down
1 change: 1 addition & 0 deletions cmd/githubgen/allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ rlankfo
swar8080
zpzhuSplunk
thmshmm
galrose
cemdk
tomasmota
m1rp
Expand Down
1 change: 1 addition & 0 deletions processor/coralogixprocessor/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../../Makefile.Common
88 changes: 88 additions & 0 deletions processor/coralogixprocessor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Coralogix Processor

<!-- status autogenerated section -->
| Status | |
| ------------- |-----------|
| Stability | [development]: traces |
| Distributions | [] |
| Warnings | [Statefulness](#warnings) |
| Issues | [![Open issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aopen%20label%3Aprocessor%2Fcoralogix%20&label=open&color=orange&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aopen+is%3Aissue+label%3Aprocessor%2Fcoralogix) [![Closed issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aclosed%20label%3Aprocessor%2Fcoralogix%20&label=closed&color=blue&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aclosed+is%3Aissue+label%3Aprocessor%2Fcoralogix) |
| [Code Owners](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/CONTRIBUTING.md#becoming-a-code-owner) | [@crobert-1](https://www.github.com/crobert-1), [@galrose](https://www.github.com/galrose), [@eyalatz](https://www.github.com/eyalatz), [@roycald245](https://www.github.com/roycald245) |

[development]: https://github.com/open-telemetry/opentelemetry-collector#development
<!-- end autogenerated section -->

## Description

The Coralogix processor adds attributes to spans that enable features in Coralogix.

## Features

### DB Statement Blueprints
crobert-1 marked this conversation as resolved.
Show resolved Hide resolved

This feature enables the processor to create blueprints from SQL queries, this means replacing any variables with `?`.
The blueprint is also hashed to be able to be used with the spanmetrics connector.
Long queries can be an issue when being stored in certain metric stores.
Blueprints alleviate this problem by using the hash as the identifying dimension on the metric, which enables
users to query metrics by blueprints.

The added attributes are `db.statement.blueprint` and `db.statement.blueprint.id`.

* `db.statement.blueprint` contains the blueprinted version of the statement, we require them to be sent to Coralogix to
display your blueprinted statement
* `db.statement.blueprint.id` contains a hash of the statement, this way we can add it as a dimension in the spanmetrics
connector and use it to query your blueprints.
* `sampling.priority` if enabled contains the value 100 for new blueprints, further explanation below.

#### Sampling

If sampling is enabled then it stores the found blueprints in an in-memory cache to be able to send only new blueprints
that haven't been seen yet.
This only adds an attribute to the span named `sampling.priority`, if the blueprint is new then the sampling priority
will be `100`.

Using this key it's possible to use either
the [Tail Sampler](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/tailsamplingprocessor)
or
the [Probabilistic Sampler](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/probabilisticsamplerprocessor)
to only send new blueprints to Coralogix.
If sampling is not enabled it won't cache anything and the `sampling.priority` attribute won't be added.

The cache is limited by the `max_cache_size_mib` configuration, if the cache is full it will remove the oldest entries
to make space for new ones.
The cache stores hashes of the queries, each hash is 8 bytes, so the number of maximum cache entries is calculated
by `max_cache_size_mib * 1024 * 1024 / 8`.

## Config
crobert-1 marked this conversation as resolved.
Show resolved Hide resolved

* `db_statement_blueprints`
* `sampling`:
* `enabled`: (default: `false`) If enabled, adds the attribute `sampling.priority` with a value of `100` to spans with new
blueprints.
Refer to the [Sampling section](#sampling) for more information.
* `max_cache_size_mib` (default: `1024`) The size of the cache in mebibytes to store seen blueprints hashes.

crobert-1 marked this conversation as resolved.
Show resolved Hide resolved
### Basic Setup
crobert-1 marked this conversation as resolved.
Show resolved Hide resolved

This setup is without sampling meaning no `sampling.priority` attribute will be added to spans.
The cache will be disabled.

```yaml
galrose marked this conversation as resolved.
Show resolved Hide resolved
processors:
coralogix:
db_statement_blueprints:
```

### With Sampling Config

This setup will enable the cache to store seen blueprints and add the `sampling.priority` attribute to spans with new
blueprints.

```yaml
galrose marked this conversation as resolved.
Show resolved Hide resolved
processors:
coralogix:
db_statement_blueprints:
sampling:
enabled: true
max_cache_size_mib: 1024 #1GiB
```
29 changes: 29 additions & 0 deletions processor/coralogixprocessor/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package coralogixprocessor // import "github.com/open-telemetry/opentelemetry-collector-contrib/processor/coralogixprocessor"

import "fmt"

type samplingConfig struct {
enabled bool `mapstructure:"enabled"`
maxCacheSizeMib int64 `mapstructure:"max_cache_size_mib"`
}

type databaseBlueprintsConfig struct {
sampling samplingConfig `mapstructure:"sampling"`
}

type Config struct {
databaseBlueprintsConfig `mapstructure:"database_blueprints_config"`
}

func (c *Config) Validate() error {
if c.databaseBlueprintsConfig.sampling.enabled && c.databaseBlueprintsConfig.sampling.maxCacheSizeMib <= 0 {
return fmt.Errorf("max_cache_size_mib must be a positive integer")
}
if c.databaseBlueprintsConfig.sampling.enabled && c.databaseBlueprintsConfig.sampling.maxCacheSizeMib != 0 {
return fmt.Errorf("max_cache_size_mib can only be defined when sampling is enabled")
}
return nil
}
6 changes: 6 additions & 0 deletions processor/coralogixprocessor/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

//go:generate mdatagen metadata.yaml

package coralogixprocessor // import "github.com/open-telemetry/opentelemetry-collector-contrib/processor/coralogixprocessor"
45 changes: 45 additions & 0 deletions processor/coralogixprocessor/factory.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 coralogixprocessor // import "github.com/open-telemetry/opentelemetry-collector-contrib/processor/coralogixprocessor"

import (
"context"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/processor"

"github.com/open-telemetry/opentelemetry-collector-contrib/processor/coralogixprocessor/internal/metadata"
)

// NewFactory returns a new factory for the Span processor.
func NewFactory() processor.Factory {
return processor.NewFactory(
metadata.Type,
createDefaultConfig,
processor.WithTraces(createTracesProcessor, component.StabilityLevelDevelopment))
}

func createDefaultConfig() component.Config {
return &Config{}
}

func createTracesProcessor(
ctx context.Context,
params processor.Settings,
baseCfg component.Config,
nextConsumer consumer.Traces,
) (processor.Traces, error) {
coralogixCfg := baseCfg.(*Config)

coralogixProcessor, err := newCoralogixProcessor(ctx,
params,
coralogixCfg,
nextConsumer)
if err != nil {
return nil, err
}

return coralogixProcessor, nil
}
135 changes: 135 additions & 0 deletions processor/coralogixprocessor/generated_component_test.go

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

Loading
Loading