Skip to content

Add a timeout param to all OTLP grpc / http export calls #4560

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 22 commits into from

Conversation

DylanRussell
Copy link
Contributor

@DylanRussell DylanRussell commented Apr 22, 2025

Description

Update export on OTLP / HTTP exporters to include a timeout param. Make timeout encompass retries, rather than being applied per-request.

Update the grpc exporter to us the retry config, which lets grpc handle retries / timeout automatically based on our config, so we can delete a lot of code.

There is no equivalent for HTTP (there is a urlilib3.RetryConfig, but it's retries are not inclusive of timeout - instead each retry gets passed the same timeout), so I manually updated the HTTP exporters.

I also cleaned up the HTTP exporter code a tiny bit.

#4183 -- similar to this PR and what's discussed in #4043, but I implemented it in as minimal a way as I could..

I updated the LogExporter and SpanExporter interfaces to include timeout_millis (MetricExporter already has it), this isn't a breaking change because @abstractmethod just checks that classes implementin have a method with a particular name, it doesn't check method parameters at all.. It does cause a pylint error, but I think that's a good thing.

In future PRs I plan to update shutdown and forceFlush to pass their timeouts along to export.. We could potentially pass these env var timeouts along to all other export calls too..

Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • [ x] New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Lots of unit tests.

Does This PR Require a Contrib Repo Change?

  • Yes. - Link to PR:
  • [x ] No.

Checklist:

  • [ x] Followed the style guidelines of this project
  • Changelogs have been updated
  • [x ] Unit tests have been added
  • Documentation has been updated

@DylanRussell DylanRussell requested a review from a team as a code owner April 22, 2025 20:36
Jayclifford345 and others added 6 commits April 23, 2025 06:16
)

* added examples

* Apply suggestions from code review

Co-authored-by: Emídio Neto <[email protected]>

* feat: added examples for metrics and logs

* fixed spelling

* Update docs/examples/metrics/reader/README.rst

Co-authored-by: Emídio Neto <[email protected]>

---------

Co-authored-by: Emídio Neto <[email protected]>
* trying sha-automation

Signed-off-by: emdneto <[email protected]>

* fix label names

* fix sha-automation core

Signed-off-by: emdneto <[email protected]>

* add new line

Signed-off-by: emdneto <[email protected]>

---------

Signed-off-by: emdneto <[email protected]>
@@ -2,6 +2,7 @@ asgiref==3.7.2
Deprecated==1.2.14
googleapis-common-protos==1.63.2
grpcio==1.66.2
grpcio-status==1.66.0
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be added as dev depdency to the package?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's only used for the tests, so I don't think so ?


# pylint: disable=invalid-name,unused-argument
def Export(self, request, context):
logger.warning("Export Request Recieved")
Copy link
Contributor

Choose a reason for hiding this comment

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

debug leftover?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I actually use this in the tests to figure out how many times export has been called.. If you know of a better way to check that let me know

def export(self, batch: Sequence[LogData]) -> LogExportResult:
return self._export(batch)
def export(
self, batch: Sequence[LogData], timeout_millis: Optional[float] = None
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't timeout_millis be Optional[int]?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't feel too strongly about it, I think float or int both are fine.. I switched it to int though

DylanRussell and others added 15 commits April 29, 2025 20:27
Bumps [jinja2](https://github.com/pallets/jinja) from 3.1.5 to 3.1.6.
- [Release notes](https://github.com/pallets/jinja/releases)
- [Changelog](https://github.com/pallets/jinja/blob/main/CHANGES.rst)
- [Commits](pallets/jinja@3.1.5...3.1.6)

---
updated-dependencies:
- dependency-name: jinja2
  dependency-version: 3.1.6
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Riccardo Magliocchetti <[email protected]>
* logs: introduce LogAttributes type

Logs attribute accepts AnyValue as AttributeValue add a type to describe
that and start using it.

* LogAttributes -> ExtendedAttributes

* Handle ExtendedAttributes in BoundedAttributes

* opentelemetry-sdk: serialize extended attributes

* Add changelog

* Fix typing

* Fix handling of not attribute values inside sequences

* Please mypy

* Please lint

* More typing

* Even more typing fixes

* Fix docs

* Fix mypy

* Update LogRecord attributes typing to match reality

* More typing

* Move changelog to unreleased

* ExtendedAttributes -> _ExtendedAttributes

* opentelemetry-sdk: keep instrumentation scope attributes as Attributes

* exporter/otlp: allow export of none values in logs attributes
)

* added examples

* Apply suggestions from code review

Co-authored-by: Emídio Neto <[email protected]>

* feat: added examples for metrics and logs

* fixed spelling

* Update docs/examples/metrics/reader/README.rst

Co-authored-by: Emídio Neto <[email protected]>

---------

Co-authored-by: Emídio Neto <[email protected]>
* trying sha-automation

Signed-off-by: emdneto <[email protected]>

* fix label names

* fix sha-automation core

Signed-off-by: emdneto <[email protected]>

* add new line

Signed-off-by: emdneto <[email protected]>

---------

Signed-off-by: emdneto <[email protected]>
@DylanRussell
Copy link
Contributor Author

I have bad merge conflicts on this PR, not sure what I did exactly but the diff is really messed up.

Moving this over to #4564

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants