Skip to content

Commit 9dfbd8d

Browse files
[pkg/translator/faro] migrate semantic convention from v1.26.0 to v1.40.0 (#48955)
Fixes #45074 `deployment.environment.name` is the replacement attribute for `deployment.environment` (Here is the reference link: https://opentelemetry.io/docs/specs/semconv/registry/attributes/deployment/#deployment-environment) #### Authorship - [x] I, a human, wrote this pull request description myself. --------- Signed-off-by: singhvibhanshu <singhvibhanshu@hotmail.com>
1 parent af2907a commit 9dfbd8d

9 files changed

Lines changed: 104 additions & 4 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: enhancement
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. receiver/filelog)
7+
component: pkg/faro
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Migrate deployment.environment (v1.26.0) semantic convention to deployment.environment.name (v1.40.0)
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [45074]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: []
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[comment]: <> (Code generated by mdatagen. DO NOT EDIT.)
2+
3+
# faro
4+
5+
## Feature Gates
6+
7+
This component has the following feature gates:
8+
9+
| Feature Gate | Stage | Description | From Version | To Version | Reference |
10+
| ------------ | ----- | ----------- | ------------ | ---------- | --------- |
11+
| `pkg.translator.faro.DontEmitV0DeploymentEnvironmentConventions` | alpha | When enabled, the Faro translator no longer emits the deprecated deployment.environment attribute (semconv v1.26.0). Requires pkg.translator.faro.EmitV1DeploymentEnvironmentConventions to also be enabled. | v0.155.0 | N/A | [Link](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/45074) |
12+
| `pkg.translator.faro.EmitV1DeploymentEnvironmentConventions` | alpha | When enabled, the Faro translator emits deployment.environment.name (semconv v1.40.0) instead of the deprecated deployment.environment (semconv v1.26.0). | v0.155.0 | N/A | [Link](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/45074) |
13+
14+
For more information about feature gates, see the [Feature Gates](https://github.com/open-telemetry/opentelemetry-collector/blob/main/featuregate/README.md) documentation.

pkg/translator/faro/faro_to_logs.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import (
2121
conventionsv126 "go.opentelemetry.io/otel/semconv/v1.26.0"
2222
conventions "go.opentelemetry.io/otel/semconv/v1.40.0"
2323
"go.uber.org/multierr"
24+
25+
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/faro/internal/metadata"
2426
)
2527

2628
type kvTime struct {
@@ -124,7 +126,12 @@ func TranslateToLogs(ctx context.Context, payload faroTypes.Payload) (plog.Logs,
124126
rls := logs.ResourceLogs().AppendEmpty()
125127
rls.Resource().Attributes().PutStr(string(conventions.ServiceNameKey), payload.Meta.App.Name)
126128
rls.Resource().Attributes().PutStr(string(conventions.ServiceVersionKey), payload.Meta.App.Version)
127-
rls.Resource().Attributes().PutStr(string(conventionsv126.DeploymentEnvironmentKey), payload.Meta.App.Environment)
129+
if !metadata.PkgTranslatorFaroDontEmitV0DeploymentEnvironmentConventionsFeatureGate.IsEnabled() {
130+
rls.Resource().Attributes().PutStr(string(conventionsv126.DeploymentEnvironmentKey), payload.Meta.App.Environment)
131+
}
132+
if metadata.PkgTranslatorFaroEmitV1DeploymentEnvironmentConventionsFeatureGate.IsEnabled() {
133+
rls.Resource().Attributes().PutStr(string(conventions.DeploymentEnvironmentNameKey), payload.Meta.App.Environment)
134+
}
128135
if payload.Meta.App.Namespace != "" {
129136
rls.Resource().Attributes().PutStr(string(conventions.ServiceNamespaceKey), payload.Meta.App.Namespace)
130137
}

pkg/translator/faro/faro_to_traces.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import (
1212
"go.opentelemetry.io/otel/attribute"
1313
conventionsv126 "go.opentelemetry.io/otel/semconv/v1.26.0"
1414
conventions "go.opentelemetry.io/otel/semconv/v1.40.0"
15+
16+
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/faro/internal/metadata"
1517
)
1618

1719
// TranslateToTraces converts faro.Payload into Traces pipeline data
@@ -33,7 +35,12 @@ func TranslateToTraces(ctx context.Context, payload faroTypes.Payload) (ptrace.T
3335
payload.Traces.Traces.ResourceSpans().At(i).CopyTo(frs)
3436
frs.Resource().Attributes().PutStr(string(conventions.ServiceNameKey), payload.Meta.App.Name)
3537
frs.Resource().Attributes().PutStr(string(conventions.ServiceVersionKey), payload.Meta.App.Version)
36-
frs.Resource().Attributes().PutStr(string(conventionsv126.DeploymentEnvironmentKey), payload.Meta.App.Environment)
38+
if !metadata.PkgTranslatorFaroDontEmitV0DeploymentEnvironmentConventionsFeatureGate.IsEnabled() {
39+
frs.Resource().Attributes().PutStr(string(conventionsv126.DeploymentEnvironmentKey), payload.Meta.App.Environment)
40+
}
41+
if metadata.PkgTranslatorFaroEmitV1DeploymentEnvironmentConventionsFeatureGate.IsEnabled() {
42+
frs.Resource().Attributes().PutStr(string(conventions.DeploymentEnvironmentNameKey), payload.Meta.App.Environment)
43+
}
3744

3845
if payload.Meta.App.Namespace != "" {
3946
frs.Resource().Attributes().PutStr(string(conventions.ServiceNamespaceKey), payload.Meta.App.Namespace)

pkg/translator/faro/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ require (
1010
github.com/stretchr/testify v1.11.1
1111
github.com/wk8/go-ordered-map/v2 v2.1.8
1212
github.com/zeebo/xxh3 v1.1.0
13+
go.opentelemetry.io/collector/featuregate v1.60.1-0.20260611154946-8ae0933981eb
1314
go.opentelemetry.io/collector/pdata v1.60.1-0.20260611154946-8ae0933981eb
1415
go.opentelemetry.io/otel v1.44.0
1516
go.uber.org/goleak v1.3.0
@@ -35,7 +36,6 @@ require (
3536
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.154.0 // indirect
3637
github.com/pmezard/go-difflib v1.0.0 // indirect
3738
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
38-
go.opentelemetry.io/collector/featuregate v1.60.1-0.20260611154946-8ae0933981eb // indirect
3939
go.opentelemetry.io/collector/pdata/pprofile v0.154.1-0.20260611154946-8ae0933981eb // indirect
4040
go.opentelemetry.io/collector/pdata/xpdata v0.154.1-0.20260611154946-8ae0933981eb // indirect
4141
go.opentelemetry.io/otel/metric v1.44.0 // indirect

pkg/translator/faro/internal/metadata/generated_feature_gates.go

Lines changed: 23 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/translator/faro/logs_to_faro.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ func extractAppFromKeyVal(kv map[string]string, rl pcommon.Resource) faroTypes.A
405405
if key == string(conventions.ServiceVersionKey) {
406406
app.Version = val.Str()
407407
}
408-
if key == string(conventionsv126.DeploymentEnvironmentKey) {
408+
if key == string(conventionsv126.DeploymentEnvironmentKey) || key == string(conventions.DeploymentEnvironmentNameKey) {
409409
app.Environment = val.Str()
410410
}
411411
// force the app name stored in resource attribute service.name

pkg/translator/faro/metadata.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,23 @@ status:
77
alpha: [ traces, logs ]
88
codeowners:
99
active: [mar4uk, rlankfo]
10+
11+
feature_gates:
12+
- id: pkg.translator.faro.DontEmitV0DeploymentEnvironmentConventions
13+
stage: alpha
14+
description: >-
15+
When enabled, the Faro translator no longer emits the deprecated
16+
deployment.environment attribute (semconv v1.26.0).
17+
Requires pkg.translator.faro.EmitV1DeploymentEnvironmentConventions to also be enabled.
18+
from_version: v0.155.0
19+
reference_url: https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/45074
20+
skip_strict_validation: true
21+
- id: pkg.translator.faro.EmitV1DeploymentEnvironmentConventions
22+
stage: alpha
23+
description: >-
24+
When enabled, the Faro translator emits deployment.environment.name
25+
(semconv v1.40.0) instead of the deprecated deployment.environment
26+
(semconv v1.26.0).
27+
from_version: v0.155.0
28+
reference_url: https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/45074
29+
skip_strict_validation: true

pkg/translator/faro/traces_to_faro.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ func extractMetaFromResourceAttributes(resourceAttributes pcommon.Map) faroTypes
107107
}
108108
if environment, ok := resourceAttributes.Get(string(conventionsv126.DeploymentEnvironmentKey)); ok {
109109
app.Environment = environment.Str()
110+
} else if environment, ok := resourceAttributes.Get(string(conventions.DeploymentEnvironmentNameKey)); ok {
111+
app.Environment = environment.Str()
110112
}
111113
if appBundleID, ok := resourceAttributes.Get(faroAppBundleID); ok {
112114
app.BundleID = appBundleID.Str()

0 commit comments

Comments
 (0)