Skip to content

Conversation

@joshlebed
Copy link
Collaborator

@joshlebed joshlebed commented Aug 18, 2025

TL;DR

Refactored OpenTelemetry context and baggage handling for improved readability and maintainability.

What changed?

  • Simplified the OpenTelemetry context and baggage handling in eval.py and eval_dataset.py by using variable reassignment instead of creating new variables
  • Refactored the attribute setting logic in span_processor.py to use a loop for handling multiple baggage keys, reducing code duplication

How to test?

  1. Run existing tests to ensure the OpenTelemetry context and baggage functionality still works correctly
  2. Verify that spans are still properly created with the correct attributes
  3. Check that experiment tracking continues to function as expected

Why make this change?

This refactoring improves code readability and maintainability by:

  • Reducing variable name complexity (using context instead of context_with_modified_baggage)
  • Eliminating redundant code through variable reassignment
  • Consolidating similar logic in span_processor.py into a loop to reduce duplication
  • Making the code more concise while preserving the same functionality

Copy link
Collaborator Author


How to use the Graphite Merge Queue

Add the label merge-queue to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@joshlebed joshlebed marked this pull request as ready for review August 18, 2025 19:18
@joshlebed joshlebed requested a review from viveknair August 18, 2025 19:18
Copy link
Contributor

@viveknair viveknair left a comment

Choose a reason for hiding this comment

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

lgtm

@graphite-app
Copy link
Contributor

graphite-app bot commented Aug 19, 2025

Merge activity

### TL;DR

Refactored OpenTelemetry context and baggage handling for improved readability and maintainability.

### What changed?

- Simplified the OpenTelemetry context and baggage handling in `eval.py` and `eval_dataset.py` by using variable reassignment instead of creating new variables
- Refactored the attribute setting logic in `span_processor.py` to use a loop for handling multiple baggage keys, reducing code duplication

### How to test?

1. Run existing tests to ensure the OpenTelemetry context and baggage functionality still works correctly
2. Verify that spans are still properly created with the correct attributes
3. Check that experiment tracking continues to function as expected

### Why make this change?

This refactoring improves code readability and maintainability by:

- Reducing variable name complexity (using `context` instead of `context_with_modified_baggage`)
- Eliminating redundant code through variable reassignment
- Consolidating similar logic in `span_processor.py` into a loop to reduce duplication
- Making the code more concise while preserving the same functionality
@graphite-app graphite-app bot force-pushed the josh/clean-up-python-sdk-test-spans branch from ad1394b to 4f4298b Compare August 19, 2025 15:48
@graphite-app graphite-app bot merged commit 4f4298b into main Aug 19, 2025
23 checks passed
@stainless-app stainless-app bot mentioned this pull request Aug 19, 2025
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.

3 participants