Skip to content

[exporter/elasticsearch] Add internal telemetry for bulk indexer#41254

Merged
songy23 merged 12 commits into
open-telemetry:mainfrom
lahsivjar:38610_additional_es_telemetry
Jul 11, 2025
Merged

[exporter/elasticsearch] Add internal telemetry for bulk indexer#41254
songy23 merged 12 commits into
open-telemetry:mainfrom
lahsivjar:38610_additional_es_telemetry

Conversation

@lahsivjar

Copy link
Copy Markdown
Member

Description

Adds additional telemetry to Elasticsearch exporter, mostly to observe the docappender.

Link to tracking issue

Fixes #38610

Testing

Unit tests added

Documentation

Mdatagen docs updated

Comment on lines -241 to -243
type bulkIndexerStats struct {
docsIndexed atomic.Int64
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[For reviewers] I removed the bulkIndexerStats since it was used in tests for assertions but the same thing can now be done by the metrics. Let me know if I missed something here.

Comment on lines +397 to +400
itemsCount := bi.Items()
if itemsCount == 0 {
return docappender.BulkIndexerResponseStat{}, nil
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[For reviewers] Added this to short-circuit no items in the indexer. I couldn't think of any side-effects but let me know if I am missing something.

case code == http.StatusTooManyRequests:
outcome = "too_many"
case code >= 500:
outcome = "failed_server"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[For reviewers] I was hoping mdatagen would generate some code/enums for the defined attributes but I don't think it does (or am I missing some config?). Anyway, these are used a couple of places so we can think of defining them as consts but I didn't think it necessary for now - let me know if you think otherwise.

}

func (w *asyncBulkIndexerWorker) flush() {
// TODO (lahsivjar): Should use proper context else client metadata will not be accessible

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[For reviewers] Will create a follow-up issue/PR for this

level: alpha
enabled: true
description: Count of document retries.
extended_documentation: Only document level retries are captured, whole bulk request retries are not captured.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[For reviewers] This might come out as a bit surprising (since if the full request is 429 there are, by definition, docs in there that were retried). If I am reading the code right, we do something similar in go-docappender too (ref).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

request level retries are done by es client, not by docappender / es exporter. So I'm not too surprised.

@carsonip carsonip left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, great start!

Comment thread exporter/elasticsearchexporter/bulkindexer.go Outdated
level: alpha
enabled: true
description: Count of document retries.
extended_documentation: Only document level retries are captured, whole bulk request retries are not captured.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

request level retries are done by es client, not by docappender / es exporter. So I'm not too surprised.

Comment thread exporter/elasticsearchexporter/metadata.yaml Outdated
Comment thread exporter/elasticsearchexporter/metadata.yaml Outdated
Comment thread exporter/elasticsearchexporter/bulkindexer.go Outdated

@carsonip carsonip left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks!

Comment thread exporter/elasticsearchexporter/metadata.yaml Outdated
Comment thread exporter/elasticsearchexporter/metadata.yaml Outdated
@edmocosta

Copy link
Copy Markdown
Contributor

We should be good to merge this one. PR's author is also a code owner, and it was approved by another one.

@edmocosta edmocosta added the ready to merge Code review completed; ready to merge by maintainers label Jul 11, 2025
@songy23 songy23 merged commit 3c96d83 into open-telemetry:main Jul 11, 2025
187 checks passed
@github-actions github-actions Bot added this to the next release milestone Jul 11, 2025
@lahsivjar lahsivjar deleted the 38610_additional_es_telemetry branch July 11, 2025 19:12
andrzej-stencel pushed a commit that referenced this pull request Jul 15, 2025
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
PR
#41254
introduced additional telemetry for ES exporter bulk indexers, however,
it missed shuting down the telemetry builder. The changes are not
released yet so I have not added any changelog.

<!-- Issue number (e.g. #1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
Related to  #38610 

<!--Describe what testing was performed and which tests were added.-->
#### Testing
N/A

<!--Describe the documentation added.-->
#### Documentation
N/A
<!--Please delete paragraphs that you did not use before submitting.-->
Dylan-M pushed a commit to Dylan-M/opentelemetry-collector-contrib that referenced this pull request Aug 5, 2025
…n-telemetry#41254)

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description

Adds additional telemetry to Elasticsearch exporter, mostly to observe
the docappender.

<!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
Fixes
open-telemetry#38610

<!--Describe what testing was performed and which tests were added.-->
#### Testing
Unit tests added

<!--Describe the documentation added.-->
#### Documentation
Mdatagen docs updated

<!--Please delete paragraphs that you did not use before submitting.-->
Dylan-M pushed a commit to Dylan-M/opentelemetry-collector-contrib that referenced this pull request Aug 5, 2025
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
PR
open-telemetry#41254
introduced additional telemetry for ES exporter bulk indexers, however,
it missed shuting down the telemetry builder. The changes are not
released yet so I have not added any changelog.

<!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
Related to  open-telemetry#38610 

<!--Describe what testing was performed and which tests were added.-->
#### Testing
N/A

<!--Describe the documentation added.-->
#### Documentation
N/A
<!--Please delete paragraphs that you did not use before submitting.-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

exporter/elasticsearch ready to merge Code review completed; ready to merge by maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[exporter/elasticsearch] Additional telemetry e.g. docappender metrics

4 participants