Skip to content

Trace listener - #7

Closed
crest42 wants to merge 4 commits into
Checkmk:mainfrom
crest42:trace_listener
Closed

crest42 wants to merge 4 commits into
Checkmk:mainfrom
crest42:trace_listener

Conversation

@crest42

@crest42 crest42 commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

Python 3.10 is end of life. The CI matrix covers 3.11 to 3.15, and the
future import of annotations that Python 3.8 needed goes. mypy and
ruff move to their latest versions; the ruff configuration follows the
Checkmk repository in leaving the flake8-type-checking and pydocstyle
families off.
The keyword logged through the root logger, which ruff's LOG015
rejects. A logger named after the module lets the message be filtered
by name; Robot Framework captures it into the log the same way.
@crest42
crest42 force-pushed the trace_listener branch 2 times, most recently from 5757a7e to 5cfa1d6 Compare November 18, 2026 11:23
The keyword moves from RobotmkLibrary/__init__.py to
RobotmkLibrary/runtime/__init__.py; the package re-exports it, so
Library RobotmkLibrary keeps working, and Library RobotmkLibrary.runtime
imports the runtime keywords alone. The README documents the keyword.

robotframework becomes a dependency, and an integration test pins the
keyword list of the package through libdoc. pytest joins the dev tools
and the workflow; mypy checks the tests too, with calls into the
untyped robot package excluded from disallow_untyped_calls and the
Any-typed values it returns tolerated in tests.
RobotmkLibrary.instrumentation.listener.RobotmkListener exports one
trace per robot run over OTLP/HTTP: suite, test and keyword spans with
rf.* attributes and the Robot Framework status, log messages as log
records of the open span, embedded screenshots as image records. The
Checkmk identity is read from CHECKMK_RESOURCE_ATTRIBUTES.

The providers are registered as the process globals so that other
instrumentations nest below the running keyword; a provider registered
earlier is an error. The package exposes __version__ from the installed
metadata as the instrumentation scope version. The library depends on
opentelemetry-sdk and the OTLP/HTTP exporter.
@crest42

crest42 commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator Author

@jherbel

@crest42
crest42 requested a review from jherbel November 18, 2026 12:34

@jherbel jherbel left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Very nice, thanks! Missing tests are OK, since we explicitly agreed that they will come in a follow-up change.

Mainly cosmetic comments + the Python version changes in here. Also, for next time: Please move monitor_subsequent_keyword_runtime in a separate change.

strategy:
matrix:
python_version:
- "3.8"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should this be in here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

You mean in this PR? I have a separate PR for only the python changes and the packaging, but I have never used stacked PRs and was not sure how to get this into review without including the full chain. See: #6

I considered looking into stacked PRs but I figured its small enough so we can do this in a single PR. If you prefer we can merge #6 before and then rebase this change before merging.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@@ -0,0 +1,20 @@
"""Keywords for the runtime monitoring of the Checkmk test services."""

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggestions: let's name the sub-package keyword_monitoring. I suspect that we might implement more of that in the future.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done in #12

Comment thread pyproject.toml
]
requires-python = ">=3.8"
dependencies = []
requires-python = ">=3.11"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

see above

Comment on lines +83 to +90
class _EmbeddedImage(NamedTuple):
media_type: str
payload: str


class _OpenSpan(NamedTuple):
span: trace.Span
token: Token[Context]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can we use frozen dataclasses instead?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done in #9

@jherbel

jherbel commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator

Regarding the Python version changes: If you need them here, we could try this: https://docs.github.com/en/pull-requests/how-tos/stacked-pull-requests
I have never tried it out myself.

@crest42

crest42 commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator Author

closing this in favor of the stacked PRs

@crest42 crest42 closed this Nov 18, 2026
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.

2 participants