Skip to content

Commit

Permalink
feat(sumologicexporter): remove translating attributes
Browse files Browse the repository at this point in the history
This feature has been deprecated in v0.56 and now is being removed.
  • Loading branch information
aboguszewski-sumo committed Jul 22, 2022
1 parent 7e5764a commit e0ee9d5
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 1,044 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

### Removed

- feat(sumologicexporter): remove translating attributes ([upgrade guide][upgrade_guide_unreleased_moved_translation])

## [v0.56.0-sumo-0]

### Released 2022-07-22
Expand Down
53 changes: 1 addition & 52 deletions pkg/exporter/sumologicexporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,6 @@ exporters:
# default = false
flatten_body: {true, false}

# DEPRECATED
# translate_attributes specifies whether attributes should be translated
# from OpenTelemetry to Sumo Logic conventions;
# see "Attribute translation" documentation chapter from this document,
# default = true
translate_attributes: {true, false}

# DEPRECATED
# Specifies whether telegraf metric names should be translated to match
# Sumo Logic conventions expected in Sumo Logic host related apps (for example
Expand Down Expand Up @@ -141,48 +134,6 @@ exporters:
[sumologicextension]: ./../../extension/sumologicextension
## Attribute translation
**Note**: This functionality has been moved to the [sumologicschemaprocessor](../../processor/sumologicschemaprocessor/) and is now deprecated.
Please check the [upgrade guide](../../../docs/Upgrading.md#sumologic-exporter-drop-support-for-translating-attributes) for migrating instructions.
Attribute translation changes some of the attribute keys from OpenTelemetry convention to Sumo Logic convention.
For example, OpenTelemetry convention for the attribute containing Kubernetes pod name is `k8s.pod.name`,
but Sumo Logic expects it to be in attribute named `pod`.

If attribute with target name eg. `pod` already exists,
translation is not being done for corresponding attribute (`k8s.pod.name` in this example).

This feature is turned on by default.
To turn it off, set the `translate_attributes` configuration option to `false`.
Note that this may cause some of Sumo Logic apps, built-in dashboards to not work correctly.

Below is a list of all attribute keys that are being translated.

| OTC key name | Sumo Logic key name |
|---------------------------|---------------------|
| `cloud.account.id` | `AccountId` |
| `cloud.availability_zone` | `AvailabilityZone` |
| `cloud.platform` | `aws_service` |
| `cloud.region` | `Region` |
| `host.id` | `InstanceId` |
| `host.name` | `host` |
| `host.type` | `InstanceType` |
| `k8s.cluster.name` | `Cluster` |
| `k8s.container.name` | `container` |
| `k8s.daemonset.name` | `daemonset` |
| `k8s.deployment.name` | `deployment` |
| `k8s.namespace.name` | `namespace` |
| `k8s.node.name` | `node` |
| `k8s.service.name` | `service` |
| `k8s.pod.hostname` | `host` |
| `k8s.pod.name` | `pod` |
| `k8s.pod.uid` | `pod_id` |
| `k8s.replicaset.name` | `replicaset` |
| `k8s.statefulset.name` | `statefulset` |
| `service.name` | `service` |
| `log.file.path_resolved` | `_sourceName` |

## Source Templates
You can specify a template with an attribute for `source_category`, `source_name`,
Expand All @@ -191,9 +142,7 @@ can be used this way.

For example, when there is an attribute `my_attr`: `my_value`, `metrics/%{my_attr}`
would be expanded to `metrics/my_value`.
Use OpenTelemetry attribute names like `k8s.pod.name` instead of `pod`,
even when [attribute translation](#attribute-translation)
is turned on.
Use OpenTelemetry attribute names like `k8s.pod.name` instead of `pod`.

If an attribute is not found, it is replaced with `undefined`.
For example, `%{existing_attr}/%{nonexistent_attr}` becomes `value-of-existing-attr/undefined`.
Expand Down
20 changes: 10 additions & 10 deletions pkg/exporter/sumologicexporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,16 @@ type Config struct {
// The format of traces you will be sending, currently only otlp format is supported
TraceFormat TraceFormatType `mapstructure:"trace_format"`

// DEPRECATED
// Specifies whether attributes should be translated
// from OpenTelemetry standard to Sumo conventions (for example `cloud.account.id` => `accountId`
// `k8s.pod.name` => `pod` etc).
TranslateAttributes bool `mapstructure:"translate_attributes"`
// DEPRECATED
// Specifies whether telegraf metric names should be translated to match
// Sumo conventions expected in Sumo host related apps (for example
// `procstat_num_threads` => `Proc_Threads` or `cpu_usage_irq` => `CPU_Irq`).
TranslateTelegrafMetrics bool `mapstructure:"translate_telegraf_attributes"`

// DEPRECATED: The below attribute only exists so we can print a nicer error
// message about not supporting it anymore.
MetadataAttributes []string `mapstructure:"metadata_attributes"`
// DEPRECATED: The below attributes only exist so we can print a nicer error
// message about not supporting them anymore.
TranslateAttributes bool `mapstructure:"translate_attributes"`
MetadataAttributes []string `mapstructure:"metadata_attributes"`

// Attribute used by routingprocessor which should be dropped during data ingestion
// This is workaround for the following issue:
Expand Down Expand Up @@ -138,6 +134,12 @@ Please consult the changelog at https://github.com/SumoLogic/sumologic-otel-coll
)
}

if cfg.TranslateAttributes {
return fmt.Errorf(`*Deprecation warning*: translate_attributes is not supported anymore.
Please consult the changelog at https://github.com/SumoLogic/sumologic-otel-collector/releases/tag/v0.59.0-sumo-0`,
)
}

switch cfg.LogFormat {
case OTLPLogFormat:
case JSONFormat:
Expand Down Expand Up @@ -261,8 +263,6 @@ const (
DefaultSourceHost string = ""
// DefaultClient defines default Client
DefaultClient string = "otelcol"
// DefaultTranslateAttributes defines default TranslateAttributes
DefaultTranslateAttributes bool = true
// DefaultTranslateTelegrafMetrics defines default TranslateTelegrafMetrics
DefaultTranslateTelegrafMetrics bool = true
// DefaultClearTimestamp defines default ClearLogsTimestamp value
Expand Down
25 changes: 0 additions & 25 deletions pkg/exporter/sumologicexporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,6 @@ const (
tracesDataUrl = "/api/v1/collector/traces"
)

const translationDeprecationBanner = `
***********************************************************************************************************************************************************
*** Translating attributes is deprecated and is going to be dropped soon. Please see the migration document: ***
*** https://github.com/SumoLogic/sumologic-otel-collector/blob/main/docs/Upgrading.md#sumologic-exporter-drop-support-for-translating-attributes. ***
***********************************************************************************************************************************************************
`

const telegrafTranslationDeprecationBanner = `
***********************************************************************************************************************************************************
*** Translating Telegraf metric names is deprecated and is going to be dropped soon. Please see the migration document: ***
Expand Down Expand Up @@ -77,14 +70,6 @@ type sumologicexporter struct {
}

func initExporter(cfg *Config, createSettings component.ExporterCreateSettings) (*sumologicexporter, error) {
if cfg.TranslateAttributes {
createSettings.Logger.Warn(translationDeprecationBanner)

cfg.SourceCategory = translateConfigValue(cfg.SourceCategory)
cfg.SourceHost = translateConfigValue(cfg.SourceHost)
cfg.SourceName = translateConfigValue(cfg.SourceName)
}

if cfg.TranslateTelegrafMetrics {
createSettings.Logger.Warn(telegrafTranslationDeprecationBanner)
}
Expand Down Expand Up @@ -243,9 +228,6 @@ func (se *sumologicexporter) pushLogsData(ctx context.Context, ld plog.Logs) err

se.dropRoutingAttribute(rl.Resource().Attributes())
currentMetadata := newFields(rl.Resource().Attributes())
if se.config.TranslateAttributes {
currentMetadata.translateAttributes()
}

if droppedRecords, err := sdr.sendNonOTLPLogs(ctx, rl, currentMetadata); err != nil {
dropped = append(dropped, droppedResourceRecords{
Expand Down Expand Up @@ -312,13 +294,6 @@ func (se *sumologicexporter) pushMetricsData(ctx context.Context, md pmetric.Met

se.dropRoutingAttribute(rm.Resource().Attributes())

// TODO: Move these modifications to the Sumo schema processor
// we shouldn't modify data in an exporter, but these modifications are idempotent and therefore harmless
if se.config.TranslateAttributes {
translateAttributes(rm.Resource().Attributes()).
CopyTo(rm.Resource().Attributes())
}

if se.config.TranslateTelegrafMetrics {
for i := 0; i < rm.ScopeMetrics().Len(); i++ {
metricsSlice := rm.ScopeMetrics().At(i).Metrics()
Expand Down
Loading

0 comments on commit e0ee9d5

Please sign in to comment.