Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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/fix_47543.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: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. receiver/filelog)
component: extension/azure_encoding

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Migrate semantic conventions to v1.40.0

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

# (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: []
18 changes: 18 additions & 0 deletions extension/encoding/azureencodingextension/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,24 @@ receivers:
encoding: azure_encoding
```

### Semantic Conventions Compatibility

This extension follows Collector-native semconv migration gates for log attribute key migrations.

The following feature gates control migration of legacy log keys (v0) to stable keys (v1):

- `extension.azureencoding.EmitV1LogConventions`
- `extension.azureencoding.DontEmitV0LogConventions`

Behavior matrix:

| EmitV1 | DontEmitV0 | Behavior |
| --- | --- | --- |
| false | false | Emit v0 conventions only (default) |
| true | false | Emit both v0 and v1 conventions |
| true | true | Emit v1 conventions only |
| false | true | Invalid configuration (startup error) |

### Log format identification

All logs processed by this extension are automatically tagged with an `encoding.format` attribute at the scope level to identify the log family. This allows you to filter and route logs by Azure service while keeping the data model consistent at the family level.
Expand Down
14 changes: 14 additions & 0 deletions extension/encoding/azureencodingextension/documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[comment]: <> (Code generated by mdatagen. DO NOT EDIT.)

# azure_encoding

## Feature Gates

This component has the following feature gates:

| Feature Gate | Stage | Description | From Version | To Version | Reference |
| ------------ | ----- | ----------- | ------------ | ---------- | --------- |
| `extension.azureencoding.DontEmitV0LogConventions` | alpha | When enabled, v0 semconv log attribute names are not emitted. | v0.149.0 | N/A | [Link](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/47543) |
| `extension.azureencoding.EmitV1LogConventions` | alpha | When enabled, v1 semconv log attribute names are emitted. | v0.149.0 | N/A | [Link](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/47543) |

For more information about feature gates, see the [Feature Gates](https://github.com/open-telemetry/opentelemetry-collector/blob/main/featuregate/README.md) documentation.
21 changes: 20 additions & 1 deletion extension/encoding/azureencodingextension/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ package azureencodingextension // import "github.com/open-telemetry/opentelemetr

import (
"context"
"errors"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/pdata/plog"
"go.opentelemetry.io/collector/pdata/pmetric"
"go.opentelemetry.io/collector/pdata/ptrace"
"go.uber.org/zap"

"github.com/open-telemetry/opentelemetry-collector-contrib/extension/encoding"
"github.com/open-telemetry/opentelemetry-collector-contrib/extension/encoding/azureencodingextension/internal/metadata"
)

var (
Expand All @@ -22,6 +25,7 @@ var (

type azureExtension struct {
config *Config
logger *zap.Logger
logUnmarshaler plog.Unmarshaler
traceUnmarshaler ptrace.Unmarshaler
metricUnmarshaler pmetric.Unmarshaler
Expand All @@ -39,7 +43,22 @@ func (ex *azureExtension) UnmarshalMetrics(buf []byte) (pmetric.Metrics, error)
return ex.metricUnmarshaler.UnmarshalMetrics(buf)
}

func (*azureExtension) Start(context.Context, component.Host) error {
func (ex *azureExtension) Start(_ context.Context, _ component.Host) error {
if metadata.ExtensionAzureencodingDontEmitV0LogConventionsFeatureGate.IsEnabled() &&
!metadata.ExtensionAzureencodingEmitV1LogConventionsFeatureGate.IsEnabled() {
err := errors.New("extension.azureencoding.DontEmitV0LogConventions cannot be enabled without enabling extension.azureencoding.EmitV1LogConventions")
ex.logger.Error("Invalid feature gate combination", zap.Error(err))
return err
}

if !metadata.ExtensionAzureencodingDontEmitV0LogConventionsFeatureGate.IsEnabled() {
ex.logger.Warn(
"[WARNING] Azure encoding logs currently emit legacy semconv attributes. " +
"To opt in to v1 semconv attributes, enable extension.azureencoding.EmitV1LogConventions and " +
"extension.azureencoding.DontEmitV0LogConventions feature gates.",
)
}

return nil
}

Expand Down
1 change: 1 addition & 0 deletions extension/encoding/azureencodingextension/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func createExtension(_ context.Context, settings extension.Settings, cfg compone

return &azureExtension{
config: config,
logger: settings.Logger,
logUnmarshaler: logs.NewAzureResourceLogsUnmarshaler(
settings.BuildInfo,
settings.Logger,
Expand Down
2 changes: 1 addition & 1 deletion extension/encoding/azureencodingextension/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ require (
go.opentelemetry.io/collector/confmap/xconfmap v0.150.0
go.opentelemetry.io/collector/extension v1.56.0
go.opentelemetry.io/collector/extension/extensiontest v0.150.0
go.opentelemetry.io/collector/featuregate v1.56.0
go.opentelemetry.io/collector/pdata v1.56.0
go.opentelemetry.io/otel v1.43.0
go.opentelemetry.io/otel/trace v1.43.0
Expand All @@ -42,7 +43,6 @@ require (
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.150.0 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
go.opentelemetry.io/collector/featuregate v1.56.0 // indirect
go.opentelemetry.io/collector/internal/componentalias v0.150.0 // indirect
go.opentelemetry.io/collector/pdata/pprofile v0.150.0 // indirect
go.opentelemetry.io/collector/pdata/xpdata v0.150.0 // indirect
Expand Down

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

Original file line number Diff line number Diff line change
Expand Up @@ -695,4 +695,4 @@ Activity Logs are a type of Azure platform log that provides insight into subscr
| `currentHealthStatus` | `azure.resourcehealth.state` | Log Attribute |
| `previousHealthStatus` | `azure.resourcehealth.previous_state` | Log Attribute |
| `type` | `azure.resourcehealth.type` | Log Attribute |
| `cause` | `azure.resourcehealth.cause` | Log Attribute |
| `cause` | `azure.resourcehealth.cause` | Log Attribute |
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
conventionsv139 "go.opentelemetry.io/otel/semconv/v1.39.0"
conventions "go.opentelemetry.io/otel/semconv/v1.40.0"

"github.com/open-telemetry/opentelemetry-collector-contrib/extension/encoding/azureencodingextension/internal/metadata"
"github.com/open-telemetry/opentelemetry-collector-contrib/extension/encoding/azureencodingextension/internal/unmarshaler"
)

Expand Down Expand Up @@ -150,8 +151,13 @@ func (r *azureDataFactoryBaseLog) PutProperties(attrs pcommon.Map, _ pcommon.Val
unmarshaler.AttrPutMapIf(attrs, attributeDataFactorySystemParameters, r.Properties.SystemParameters)
unmarshaler.AttrPutMapIf(attrs, attributeDataFactoryTags, r.Properties.Tags)
// Errors
if !metadata.ExtensionAzureencodingDontEmitV0LogConventionsFeatureGate.IsEnabled() {
unmarshaler.AttrPutStrIf(attrs, string(conventionsv139.ErrorMessageKey), r.Properties.Error.Message)
}
if metadata.ExtensionAzureencodingEmitV1LogConventionsFeatureGate.IsEnabled() {
unmarshaler.AttrPutStrIf(attrs, string(conventions.ExceptionMessageKey), r.Properties.Error.Message)
}
unmarshaler.AttrPutStrIf(attrs, attributeErrorCode, r.Properties.Error.Code)
unmarshaler.AttrPutStrIf(attrs, string(conventionsv139.ErrorMessageKey), r.Properties.Error.Message)
unmarshaler.AttrPutStrIf(attrs, string(conventions.ErrorTypeKey), r.Properties.Error.FailureType)
unmarshaler.AttrPutStrIf(attrs, attributeErrorTarget, r.Properties.Error.Target)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
conventionsv139 "go.opentelemetry.io/otel/semconv/v1.39.0"
conventions "go.opentelemetry.io/otel/semconv/v1.40.0"

"github.com/open-telemetry/opentelemetry-collector-contrib/extension/encoding/azureencodingextension/internal/metadata"
"github.com/open-telemetry/opentelemetry-collector-contrib/extension/encoding/azureencodingextension/internal/unmarshaler"
)

Expand Down Expand Up @@ -164,7 +165,12 @@ func (r *azureMSDiagnosticErrorLog) PutCommonAttributes(attrs pcommon.Map, body

// Then put custom top-level attributes
unmarshaler.AttrPutStrIf(attrs, attributeAzureMSTaskName, r.TaskName)
unmarshaler.AttrPutStrIf(attrs, string(conventionsv139.ErrorMessageKey), r.ErrorMessage)
if !metadata.ExtensionAzureencodingDontEmitV0LogConventionsFeatureGate.IsEnabled() {
unmarshaler.AttrPutStrIf(attrs, string(conventionsv139.ErrorMessageKey), r.ErrorMessage)
}
if metadata.ExtensionAzureencodingEmitV1LogConventionsFeatureGate.IsEnabled() {
unmarshaler.AttrPutStrIf(attrs, string(conventions.ExceptionMessageKey), r.ErrorMessage)
}
unmarshaler.AttrPutIntNumberIf(attrs, attributeAzureMSErrorCount, r.ErrorCount)
unmarshaler.AttrPutStrIf(attrs, string(conventions.ErrorTypeKey), r.OperationResult)
}
Expand Down Expand Up @@ -309,7 +315,12 @@ func (r *azureMSOperationalLog) PutProperties(attrs pcommon.Map, _ pcommon.Value
unmarshaler.AttrPutURLParsed(attrs, r.Properties.ViaURL)
unmarshaler.AttrPutStrIf(attrs, string(conventions.AzureServiceRequestIDKey), r.Properties.TrackingID)
unmarshaler.AttrPutStrIf(attrs, attributeErrorCode, r.Properties.ErrorCode)
unmarshaler.AttrPutStrIf(attrs, string(conventionsv139.ErrorMessageKey), r.Properties.ErrorMessage)
if !metadata.ExtensionAzureencodingDontEmitV0LogConventionsFeatureGate.IsEnabled() {
unmarshaler.AttrPutStrIf(attrs, string(conventionsv139.ErrorMessageKey), r.Properties.ErrorMessage)
}
if metadata.ExtensionAzureencodingEmitV1LogConventionsFeatureGate.IsEnabled() {
unmarshaler.AttrPutStrIf(attrs, string(conventions.ExceptionMessageKey), r.Properties.ErrorMessage)
}

return nil
}
Expand Down
12 changes: 12 additions & 0 deletions extension/encoding/azureencodingextension/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,15 @@ status:
codeowners:
active: [axw, constanca-m]
distributions: [contrib]

feature_gates:
- id: extension.azureencoding.DontEmitV0LogConventions
stage: alpha
description: When enabled, v0 semconv log attribute names are not emitted.
from_version: v0.149.0
reference_url: https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/47543
- id: extension.azureencoding.EmitV1LogConventions
stage: alpha
description: When enabled, v1 semconv log attribute names are emitted.
from_version: v0.149.0
reference_url: https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/47543
Loading