-
Notifications
You must be signed in to change notification settings - Fork 8
Added OTEL tracing #196
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
base: main
Are you sure you want to change the base?
Added OTEL tracing #196
Conversation
…ded to python-zocalo
for more information, see https://pre-commit.ci
src/workflows/recipe/__init__.py
Outdated
| message = mangle_for_receiving(message) | ||
| if header.get("workflows-recipe") in {True, "True", "true", 1}: | ||
| rw = RecipeWrapper(message=message, transport=transport_layer) | ||
| logger.debug("RecipeWrapper created: %s", rw) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
debugging output left in
src/workflows/recipe/__init__.py
Outdated
|
|
||
| # Extract recipe_id on the current span | ||
| span = trace.get_current_span() | ||
| dcid = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we decided to move DCID handling elsewhere
src/workflows/recipe/__init__.py
Outdated
| if dcid: | ||
| log_extra["dcid"] = dcid |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also vestigial DCID handling
src/workflows/recipe/__init__.py
Outdated
| if recipe_id: | ||
| log_extra["recipe_id"] = recipe_id | ||
|
|
||
| logger.info("Processing recipe message", extra=log_extra) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
debug output, probably don't want to keep this for deployment (certainly not at INFO level)
| self._transport.add_middleware(otel_middleware) | ||
|
|
||
| self.log.debug("OTELTracingMiddleware added to transport layer of %s", self._service_name) | ||
| self.log.debug( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this debug output probably OK as at DEBUG level but maybe consider if it's truly useful to keep around (it might be!)
| otlp_exporter = OTLPSpanExporter( | ||
| endpoint="https://otel.tracing.diamond.ac.uk:4318/v1/traces", timeout=10 | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the zocalo configuration plugin system for this e.g. https://github.com/DiamondLightSource/python-workflows/blob/main/src/workflows/util/zocalo/configuration.py
| """ | ||
| Initialize the OpenTelemetry Tracing Middleware. | ||
| :param tracer: An OpenTelemetry tracer instance used to create spans. | ||
| """ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either:
- The declared parameters are incomplete here, and should be expanded
or - This docstring is somewhat vestigial and doesn't add much. "Init on OTELTracingMiddleware initializes the OpenTelemetry Tracing Middleware" "tracer: A trace"
In any case, I believe that most of the time we use google-style docstrings e.g. https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html
for more information, see https://pre-commit.ci
| endpoint=otel_config["endpoint"], | ||
| timeout=otel_config.get("timeout", 10), | ||
| ) | ||
| span_processor = BatchSpanProcessor(otlp_exporter) |
Check failure
Code scanning / CodeQL
Potentially uninitialized local variable Error
| timeout=otel_config.get("timeout", 10), | ||
| ) | ||
| span_processor = BatchSpanProcessor(otlp_exporter) | ||
| provider.add_span_processor(span_processor) |
Check failure
Code scanning / CodeQL
Potentially uninitialized local variable Error
Added OTEL Tracing to zocalo service