-
Notifications
You must be signed in to change notification settings - Fork 936
opentelemetry-sdk: Add ability to refresh process sensitive Resource attributes #5280
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
Open
herin049
wants to merge
26
commits into
open-telemetry:main
Choose a base branch
from
herin049:feat/tracer-provider-update-resource
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
2e6b498
opentelemetry-sdk: add ability to refresh process-sensitive resource …
herin049 59a92dc
update formatting
herin049 5e081a3
add changelog fragment
herin049 308a459
conditionally run 'os.register_at_fork' to support pypy3
herin049 c693d1c
small type hint change
herin049 3fd61b2
fix docs build errors and typechecking errors
herin049 d44e094
address copilot comments
herin049 108b919
revert uv.lock changeS
herin049 536027e
add os.waitstatus_to_exitcode() to tracer provider fork script
herin049 8be65d6
make update resource private
herin049 9d3b2f2
Merge branch 'main' into feat/tracer-provider-update-resource
herin049 acc083b
Merge branch 'main' into feat/tracer-provider-update-resource
herin049 5039afe
merge main into branch
herin049 fce36ef
simplify fork-based unit tests
herin049 29d48a2
update ServiceInstanceIdResourceDetector to return True for is_proces…
herin049 a1f8d44
Merge branch 'main' into feat/tracer-provider-update-resource
herin049 0c820c6
Merge branch 'main' into feat/tracer-provider-update-resource
herin049 2c4a6d5
Merge branch 'main' into feat/tracer-provider-update-resource
herin049 9d1ee45
switch to using is_process_dependent for ResourceDetector method
herin049 20e3b71
Merge branch 'main' into feat/tracer-provider-update-resource
herin049 acb53e1
Merge branch 'main' into feat/tracer-provider-update-resource
herin049 b5cfee7
remove all references of 'sensitive'
herin049 dc9a6c7
update changelog fragment
herin049 6e7501f
Merge branch 'main' into feat/tracer-provider-update-resource
herin049 bd906e4
merge main into current branch
herin049 59cc86b
document post-fork refresh behavior for service instance id resource …
herin049 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| `opentelemetry-sdk`: Add ability to refresh process dependent Resource attributes |
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
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
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
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
82 changes: 82 additions & 0 deletions
82
opentelemetry-sdk/tests/logs/scripts/logger_provider_resource_after_fork.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| # Copyright The OpenTelemetry Authors | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import json | ||
| import os | ||
|
|
||
| from opentelemetry._logs import LogRecord | ||
| from opentelemetry.sdk._logs import LoggerProvider | ||
| from opentelemetry.sdk._logs.export import ( | ||
| InMemoryLogRecordExporter, | ||
| SimpleLogRecordProcessor, | ||
| ) | ||
| from opentelemetry.sdk.resources import PROCESS_PID | ||
|
|
||
|
|
||
| # pylint: disable-next=too-many-locals | ||
| def main() -> None: | ||
| exporter = InMemoryLogRecordExporter() | ||
| logger_provider = LoggerProvider(shutdown_on_exit=False) | ||
| logger_provider.add_log_record_processor( | ||
| SimpleLogRecordProcessor(exporter) | ||
| ) | ||
| logger = logger_provider.get_logger("cached") | ||
| parent_pid = os.getpid() | ||
| parent_resource_pid = logger_provider.resource.attributes[PROCESS_PID] | ||
| parent_logger_pid = logger.resource.attributes[PROCESS_PID] | ||
|
|
||
| pid = os.fork() | ||
| if not pid: | ||
| child_pid = os.getpid() | ||
| new_logger = logger_provider.get_logger("new") | ||
| logger.emit(LogRecord(observed_timestamp=0, body="cached")) | ||
| new_logger.emit(LogRecord(observed_timestamp=0, body="new")) | ||
| finished_logs = exporter.get_finished_logs() | ||
| print( | ||
| json.dumps( | ||
| { | ||
| "child_pid": child_pid, | ||
| "provider_pid": logger_provider.resource.attributes[ | ||
| PROCESS_PID | ||
| ], | ||
| "cached_logger_pid": logger.resource.attributes[ | ||
| PROCESS_PID | ||
| ], | ||
| "new_logger_pid": new_logger.resource.attributes[ | ||
| PROCESS_PID | ||
| ], | ||
| "exported_resource_pids": [ | ||
| log.resource.attributes[PROCESS_PID] | ||
| for log in finished_logs | ||
| ], | ||
| "log_bodies": sorted( | ||
| log.log_record.body for log in finished_logs | ||
| ), | ||
| } | ||
| ), | ||
| flush=True, | ||
| ) | ||
| # pylint: disable-next=protected-access | ||
| os._exit(0) | ||
|
|
||
| os.waitpid(pid, 0) | ||
| print( | ||
| json.dumps( | ||
| { | ||
| "parent_pid": parent_pid, | ||
| "parent_resource_pid": parent_resource_pid, | ||
| "parent_logger_pid": parent_logger_pid, | ||
| "parent_resource_pid_after_fork": logger_provider.resource.attributes[ | ||
| PROCESS_PID | ||
| ], | ||
| "parent_logger_pid_after_fork": logger.resource.attributes[ | ||
| PROCESS_PID | ||
| ], | ||
| } | ||
| ), | ||
| flush=True, | ||
| ) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.