Fix otel_span_attr merging across config levels (#107).#108
Open
danielkatz wants to merge 1 commit into
Open
Conversation
Previously, when otel_span_attr directives were declared at both http and server levels, only the child level attributes were reported. This fix merges attributes from parent levels with child levels, ensuring all configured attributes are included in spans.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, when otel_span_attr directives were declared at both http and server levels, only the child level attributes were reported. This fix merges attributes from parent levels with child levels, ensuring all configured attributes are included in spans.
Proposed changes
This PR fixes issue #107 where
otel_span_attrdirectives declared at different configuration levels (http/server/location) were not merged. Previously, only the most specific level's attributes were reported, with parent level attributes being silently discarded.Root Cause:
The
mergeLocationConffunction insrc/http_module.cpponly inherited parent attributes when the child had none. If the child had anyotel_span_attrdirectives, the parent's attributes were completely replaced rather than merged.Solution:
mergeLocationConfto merge parent and child span attributes into a single arrayChanges:
src/http_module.cpp: Enhanced merge logic to concatenate parent and child span attributestests/test_otel.py:get_all_attrs()helper function to retrieve all values for duplicate attribute keystest_span_attr_merge()to verify http + server level mergingtest_span_attr_merge_with_location()to verify all three levels merge correctlyNGINX_CONFIGtemplate to support http/server level span attributesTesting:
All 26 tests pass, including the 2 new tests that specifically verify the merge behavior.
Fixes #107
Checklist
Before creating a PR, run through this checklist and mark each as complete.
CONTRIBUTINGdocument