Skip to content

Commit a466a0e

Browse files
authored
Merge branch 'open-telemetry:main' into main
2 parents dded7b5 + c48309c commit a466a0e

File tree

14 files changed

+210
-90
lines changed

14 files changed

+210
-90
lines changed
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: bug_fix
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: bmchelixexporter
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: "Fix distinct datapoints merged into a single metric payload"
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: [40991]
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: [user]
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: bug_fix
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: elasticsearchexporter
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Shutdown `TelemetryBuilder` on expoter shutdown
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: [41278]
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: [user]

.github/workflows/auto-update-jmx-metrics-component.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,21 +77,27 @@ jobs:
7777
7878
- name: Use CLA approved github bot
7979
run: |
80-
git config user.name opentelemetrybot
81-
git config user.email [email protected]
80+
git config user.name otelbot
81+
git config user.email [email protected]
82+
83+
- uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6
84+
id: otelbot-token
85+
with:
86+
app-id: ${{ vars.OTELBOT_APP_ID }}
87+
private-key: ${{ secrets.OTELBOT_PRIVATE_KEY }}
8288

8389
- name: Create pull request against main
8490
env:
8591
VERSION: ${{ needs.check-versions.outputs.latest-version }}
8692
# not using secrets.GITHUB_TOKEN since pull requests from that token do not run workflows
87-
GH_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }}
93+
GH_TOKEN: ${{ steps.otelbot-token.outputs.token }}
8894
run: |
8995
message="Add JMX metrics gatherer version $VERSION"
9096
body="Add JMX metrics gatherer version \`$VERSION\`.
9197
9298
cc @open-telemetry/java-contrib-approvers
9399
"
94-
branch="opentelemetrybot/add-jmx-metrics-gatherer-${VERSION}"
100+
branch="otelbot/add-jmx-metrics-gatherer-${VERSION}"
95101
96102
git checkout -b $branch
97103
git commit -a -m "$message"

.github/workflows/check-merge-freeze.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
# This condition is to avoid blocking the PR causing the freeze in the first place.
2323
if: |
2424
(!startsWith(github.event.pull_request.title || github.event.merge_group.head_commit.message, '[chore] Prepare release')) ||
25-
(!(github.event.pull_request.user.login == 'opentelemetrybot' || github.event.merge_group.head_commit.author.name == 'OpenTelemetry Bot'))
25+
(!(github.event.pull_request.user.login == 'otelbot[bot]' || github.event.merge_group.head_commit.author.login == 'otelbot[bot]'))
2626
runs-on: ubuntu-latest
2727
steps:
2828
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

.github/workflows/prepare-release.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,15 @@ jobs:
2828
with:
2929
go-version: 1.23.10
3030
cache: false
31+
- uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6
32+
id: otelbot-token
33+
with:
34+
app-id: ${{ vars.OTELBOT_APP_ID }}
35+
private-key: ${{ secrets.OTELBOT_PRIVATE_KEY }}
3136
- name: Prepare release for contrib
3237
working-directory: opentelemetry-collector-contrib
3338
env:
34-
GITHUB_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }}
39+
GITHUB_TOKEN: ${{ steps.otelbot-token.outputs.token }}
3540
REPO: open-telemetry/opentelemetry-collector-contrib
3641
CANDIDATE_BETA: ${{ inputs.candidate-beta }}
3742
CURRENT_BETA: ${{ inputs.current-beta }}

.github/workflows/scripts/check-merge-freeze.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Copyright The OpenTelemetry Authors
44
# SPDX-License-Identifier: Apache-2.0
55

6-
BLOCKERS=$( gh pr list -A opentelemetrybot -S "[chore] Prepare release" --json url -q '.[].url' -R "${REPO}" )
6+
BLOCKERS=$( gh pr list -A otelbot[bot] -S "[chore] Prepare release" --json url -q '.[].url' -R "${REPO}" )
77
if [ "${BLOCKERS}" != "" ]; then
88
echo "Merging in main is frozen, as there are open \"Prepare release\" PRs: ${BLOCKERS}"
99
echo "If you believe this is no longer true, re-run this job to unblock your PR."

.github/workflows/scripts/release-prepare-release.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ fi
1919
# Expand CURRENT_BETA to escape . character by using [.]
2020
CURRENT_BETA_ESCAPED=${CURRENT_BETA//./[.]}
2121

22-
git config user.name opentelemetrybot
23-
git config user.email 107717825+opentelemetrybot@users.noreply.github.com
22+
git config user.name otelbot
23+
git config user.email 197425009+otelbot@users.noreply.github.com
2424

2525
BRANCH="prepare-release-prs/${CANDIDATE_BETA}"
2626
git checkout -b "${BRANCH}"

.github/workflows/tidy-dependencies.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,20 @@ jobs:
3838
- name: Install Tools
3939
if: steps.go-cache.outputs.cache-hit != 'true'
4040
run: make install-tools
41+
- uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6
42+
id: otelbot-token
43+
with:
44+
app-id: ${{ vars.OTELBOT_APP_ID }}
45+
private-key: ${{ secrets.OTELBOT_PRIVATE_KEY }}
4146
- name: go mod tidy, make genotelcontribcol and make genoteltestbedcol
4247
run: |
4348
make gotidy && make genotelcontribcol && make genoteltestbedcol
44-
git config user.name opentelemetrybot
45-
git config user.email 107717825+opentelemetrybot@users.noreply.github.com
49+
git config user.name otelbot
50+
git config user.email 197425009+otelbot@users.noreply.github.com
4651
echo "git diff --exit-code || (git add . && git commit -m \"go mod tidy, make genotelcontribcol and make genoteltestbedcol\" && git push)"
4752
git diff --exit-code || (git add . && git commit -m "go mod tidy, make genotelcontribcol and make genoteltestbedcol" && git push)
4853
env:
49-
GITHUB_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }}
54+
GITHUB_TOKEN: ${{ steps.otelbot-token.outputs.token }}
5055
- uses: actions-ecosystem/action-remove-labels@2ce5d41b4b6aa8503e285553f75ed56e0a40bae0 # v1
5156
with:
5257
labels: renovatebot

.github/workflows/update-otel.yaml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,26 @@ jobs:
1717
with:
1818
path: opentelemetry-collector
1919
repository: open-telemetry/opentelemetry-collector
20+
- uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6
21+
id: otelbot-token
22+
with:
23+
app-id: ${{ vars.OTELBOT_APP_ID }}
24+
private-key: ${{ secrets.OTELBOT_PRIVATE_KEY }}
2025
- name: Update to latest opentelemetry-collector release and create a PR
2126
run: |
2227
exec > >(tee log.out) 2>&1
2328
LAST_COMMIT=$(git -C ./opentelemetry-collector/ rev-parse HEAD)
2429
cd opentelemetry-collector-contrib
25-
git config user.name opentelemetrybot
26-
git config user.email 107717825+opentelemetrybot@users.noreply.github.com
27-
branch="opentelemetrybot/update-otel-$(date +%s)"
30+
git config user.name otelbot
31+
git config user.email 197425009+otelbot@users.noreply.github.com
32+
branch="otelbot/update-otel-$(date +%s)"
2833
git checkout -b $branch
2934
make genotelcontribcol
3035
make update-otel OTEL_STABLE_VERSION=${LAST_COMMIT} OTEL_VERSION=${LAST_COMMIT}
3136
git push --set-upstream origin $branch
3237
gh pr create --base main --title "[chore] Update core dependencies" --body "This PR updates the opentelemetry-collector dependency to the latest release"
3338
env:
34-
GITHUB_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }}
39+
GITHUB_TOKEN: ${{ steps.otelbot-token.outputs.token }}
3540
- name: File an issue if the workflow failed
3641
if: failure()
3742
run: |

exporter/bmchelixexporter/internal/operationsmanagement/metrics_producer.go

Lines changed: 57 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package operationsmanagement // import "github.com/open-telemetry/opentelemetry-
55

66
import (
77
"fmt"
8+
"slices"
89

910
"go.opentelemetry.io/collector/pdata/pcommon"
1011
"go.opentelemetry.io/collector/pdata/pmetric"
@@ -57,17 +58,25 @@ func (mp *MetricsProducer) ProduceHelixPayload(metrics pmetric.Metrics) ([]BMCHe
5758

5859
// Iterate through each individual pmetric.Metric instance
5960
metrics := scopeMetric.Metrics()
61+
6062
for k := 0; k < metrics.Len(); k++ {
6163
metric := metrics.At(k)
6264

6365
// Create the payload for each metric
64-
newHelixMetric, err := mp.createHelixMetric(metric, resourceAttrs)
66+
newMetrics, err := mp.createHelixMetrics(metric, resourceAttrs)
6567
if err != nil {
66-
mp.logger.Warn("Failed to create Helix metric", zap.Error(err))
68+
mp.logger.Warn("Failed to create Helix metrics", zap.Error(err))
6769
continue
6870
}
6971

70-
helixMetrics = appendMetricWithParentEntity(helixMetrics, *newHelixMetric, containerParentEntities)
72+
// Grow the helixMetrics slice for the new metrics
73+
helixMetrics = slices.Grow(helixMetrics, len(newMetrics))
74+
75+
// Loop through the newly created metrics and append them to the helixMetrics slice
76+
// while also creating parent entities for container metrics
77+
for _, m := range newMetrics {
78+
helixMetrics = appendMetricWithParentEntity(helixMetrics, m, containerParentEntities)
79+
}
7180
}
7281
}
7382
}
@@ -106,12 +115,48 @@ func appendMetricWithParentEntity(helixMetrics []BMCHelixOMMetric, helixMetric B
106115
return append(helixMetrics, helixMetric)
107116
}
108117

109-
// createHelixMetric converts a single OpenTelemetry metric into a BMCHelixOMMetric payload
110-
func (mp *MetricsProducer) createHelixMetric(metric pmetric.Metric, resourceAttrs map[string]string) (*BMCHelixOMMetric, error) {
118+
// createHelixMetrics converts each OpenTelemetry datapoint into an individual BMCHelixOMMetric
119+
func (mp *MetricsProducer) createHelixMetrics(metric pmetric.Metric, resourceAttrs map[string]string) ([]BMCHelixOMMetric, error) {
120+
var helixMetrics []BMCHelixOMMetric
121+
122+
switch metric.Type() {
123+
case pmetric.MetricTypeSum:
124+
sliceLen := metric.Sum().DataPoints().Len()
125+
helixMetrics = slices.Grow(helixMetrics, sliceLen)
126+
for i := 0; i < sliceLen; i++ {
127+
dp := metric.Sum().DataPoints().At(i)
128+
metricPayload, err := mp.createSingleDatapointMetric(dp, metric, resourceAttrs)
129+
if err != nil {
130+
mp.logger.Warn("Failed to create Helix metric from datapoint", zap.Error(err))
131+
continue
132+
}
133+
helixMetrics = append(helixMetrics, *metricPayload)
134+
}
135+
case pmetric.MetricTypeGauge:
136+
sliceLen := metric.Gauge().DataPoints().Len()
137+
helixMetrics = slices.Grow(helixMetrics, sliceLen)
138+
for i := 0; i < sliceLen; i++ {
139+
dp := metric.Gauge().DataPoints().At(i)
140+
metricPayload, err := mp.createSingleDatapointMetric(dp, metric, resourceAttrs)
141+
if err != nil {
142+
mp.logger.Warn("Failed to create Helix metric from datapoint", zap.Error(err))
143+
continue
144+
}
145+
helixMetrics = append(helixMetrics, *metricPayload)
146+
}
147+
default:
148+
return nil, fmt.Errorf("unsupported metric type %s", metric.Type())
149+
}
150+
151+
return helixMetrics, nil
152+
}
153+
154+
// createSingleDatapointMetric creates a single BMCHelixOMMetric from a single OpenTelemetry datapoint
155+
func (mp *MetricsProducer) createSingleDatapointMetric(dp pmetric.NumberDataPoint, metric pmetric.Metric, resourceAttrs map[string]string) (*BMCHelixOMMetric, error) {
111156
labels := make(map[string]string)
112157
labels["source"] = "OTEL"
113158

114-
// Add resource attributes as labels
159+
// Add resource attributes
115160
for k, v := range resourceAttrs {
116161
labels[k] = v
117162
}
@@ -128,58 +173,20 @@ func (mp *MetricsProducer) createHelixMetric(metric pmetric.Metric, resourceAttr
128173
// Update the metric name for the BMC Helix Operations Management payload
129174
labels["metricName"] = metric.Name()
130175

131-
// Samples to hold the metric values
132-
samples := []BMCHelixOMSample{}
133-
134-
// Handle different types of metrics (sum and gauge)
135-
// BMC Helix Operations Management only supports simple metrics (sum, gauge, etc.) and not histograms or summaries
136-
switch metric.Type() {
137-
case pmetric.MetricTypeSum:
138-
dataPoints := metric.Sum().DataPoints()
139-
for i := 0; i < dataPoints.Len(); i++ {
140-
samples = mp.processDatapoint(samples, dataPoints.At(i), labels, metric, resourceAttrs)
141-
}
142-
case pmetric.MetricTypeGauge:
143-
dataPoints := metric.Gauge().DataPoints()
144-
for i := 0; i < dataPoints.Len(); i++ {
145-
samples = mp.processDatapoint(samples, dataPoints.At(i), labels, metric, resourceAttrs)
146-
}
147-
default:
148-
return nil, fmt.Errorf("unsupported metric type %s", metric.Type())
149-
}
150-
151-
// Check if the hostname is set
152-
if labels["hostname"] == "" {
153-
return nil, fmt.Errorf("hostname is required for the BMC Helix Operations Management payload but not set for metric %s", metric.Name())
154-
}
155-
156-
// Check if the entityTypeId is set
157-
if labels["entityTypeId"] == "" {
158-
return nil, fmt.Errorf("entityTypeId is required for the BMC Helix Operations Management payload but not set for metric %s", metric.Name())
176+
// Update the entity information
177+
err := mp.updateEntityInformation(labels, metric.Name(), resourceAttrs, dp.Attributes().AsRaw())
178+
if err != nil {
179+
return nil, err
159180
}
160181

161-
// Check if the entityName is set
162-
if labels["entityName"] == "" {
163-
return nil, fmt.Errorf("entityName is required for the BMC Helix Operations Management payload but not set for metric %s", metric.Name())
164-
}
182+
sample := newSample(dp)
165183

166184
return &BMCHelixOMMetric{
167185
Labels: labels,
168-
Samples: samples,
186+
Samples: []BMCHelixOMSample{sample},
169187
}, nil
170188
}
171189

172-
// Updates the metric information for the BMC Helix Operations Management payload and returns the updated samples
173-
func (mp *MetricsProducer) processDatapoint(samples []BMCHelixOMSample, dp pmetric.NumberDataPoint, labels map[string]string, metric pmetric.Metric, resourceAttrs map[string]string) []BMCHelixOMSample {
174-
// Update the entity information for the BMC Helix Operations Management payload
175-
err := mp.updateEntityInformation(labels, metric.Name(), resourceAttrs, dp.Attributes().AsRaw())
176-
if err != nil {
177-
mp.logger.Warn("Failed to update entity information", zap.Error(err))
178-
}
179-
180-
return append(samples, newSample(dp))
181-
}
182-
183190
// Update the entity information for the BMC Helix Operations Management payload
184191
func (mp *MetricsProducer) updateEntityInformation(labels map[string]string, metricName string, resourceAttrs map[string]string, dpAttributes map[string]any) error {
185192
// Try to get the hostname from resource attributes first

0 commit comments

Comments
 (0)