-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
MovieStoreGuy
merged 50 commits into
open-telemetry:main
from
galrose:coralogix-proccesor-first-pr
Aug 9, 2024
Merged
Coralogix processor first PR #33458
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 6d7fe3b
fixed toolchain
galrose 08ea9e1
Merge branch 'main' into coralogix-proccesor-first-pr
galrose 35922ee
Update processor/coralogixprocessor/metadata.yaml
galrose b53a9f3
Update processor/coralogixprocessor/doc.go
galrose 71a48f9
README.md fixes
galrose b5e1e6e
Merge remote-tracking branch 'origin/coralogix-proccesor-first-pr' in…
galrose 70e11a5
fixed naming, removed code from span.go
galrose 8bf11ae
Merge branch 'main' into coralogix-proccesor-first-pr
galrose 7a03261
Update processor/coralogixprocessor/README.md
galrose 5811865
removed max_cache_entries because of calculations, and other PR fixes
galrose 361326b
Merge remote-tracking branch 'origin/coralogix-proccesor-first-pr' in…
galrose accbe6a
Merge branch 'main' into coralogix-proccesor-first-pr
galrose 7a88b54
removed max_cache_entries from config.go
galrose 2d82f0e
Merge branch 'main' into coralogix-proccesor-first-pr
galrose b53a35b
Update processor/coralogixprocessor/README.md
galrose a20b8a6
Merge branch 'main' into coralogix-proccesor-first-pr
galrose d68c182
added more information about disabling sampling
galrose bafd1ba
Changed createSettings to settings because its depricated
galrose d600988
Merge remote-tracking branch 'origin/coralogix-proccesor-first-pr' in…
galrose e95a743
add license
galrose 2dd6c34
added enabled key to sampling
galrose f0db5df
Merge branch 'main' into coralogix-proccesor-first-pr
galrose 19b5f13
added galrose to allowlist
galrose 00e818d
Merge remote-tracking branch 'origin/coralogix-proccesor-first-pr' in…
galrose 8b7623a
added go.sum
galrose 7738f59
Merge branch 'main' into coralogix-proccesor-first-pr
galrose 7a96743
Merge branch 'main' into coralogix-proccesor-first-pr
galrose 2c7811a
added codeowners, removed unused imports and variables, updated otel …
galrose 0fc97e8
ran some more scripts to pass workflow
galrose 31c72c2
Merge branch 'main' into coralogix-proccesor-first-pr
galrose 65f3e24
Update processor/coralogixprocessor/README.md
galrose fe14dfb
Update processor/coralogixprocessor/README.md
galrose 0024f66
Update processor/coralogixprocessor/README.md
galrose 3be5c7b
Update processor/coralogixprocessor/README.md
galrose 9f4df26
Update processor/coralogixprocessor/config.go
galrose 47329a2
added @crobert-1 to code owners as well
galrose 26e7c79
fixed samplingConfig spelling mistake
galrose d17fd25
Merge branch 'main' into coralogix-proccesor-first-pr
galrose 589e800
updated collector module versions
galrose 3c5d145
updated modules
galrose af491a1
added members of my team as code owners as well
galrose a4166eb
Merge branch 'main' into coralogix-proccesor-first-pr
galrose 9f3231d
updated package versions
galrose f547190
updated module versions
galrose 7642ec9
fixed go.sum
galrose 9901e7e
Merge branch 'main' into coralogix-proccesor-first-pr
atoulme f7b3b53
updated go modules
galrose 4c6cbc2
Merge branch 'main' into coralogix-proccesor-first-pr
galrose 827ba2a
updated go modules
galrose File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,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: [] |
Validating CODEOWNERS rules …
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
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
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 |
---|---|---|
|
@@ -16,6 +16,7 @@ rlankfo | |
swar8080 | ||
zpzhuSplunk | ||
thmshmm | ||
galrose | ||
cemdk | ||
tomasmota | ||
m1rp | ||
|
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 @@ | ||
include ../../Makefile.Common |
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,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 | ||
``` |
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,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 | ||
} |
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,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" |
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,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
135
processor/coralogixprocessor/generated_component_test.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This broke a CI in mainline: https://github.com/open-telemetry/opentelemetry-collector-contrib/actions/runs/10317079346/job/28560709557#step:16:11
There was a problem hiding this comment.
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
?