Skip to content

Commit 36737e4

Browse files
committed
Resolving merge conflicts
2 parents 0a0ea3f + abd01fb commit 36737e4

File tree

4 files changed

+19
-15
lines changed
  • instrumentation
    • opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi
    • opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask
    • opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado

4 files changed

+19
-15
lines changed

CHANGELOG.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
- `opentelemetry-instrumentation-psycopg2` extended the sql commenter support of dbapi into psycopg2
1313
([#940](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/940))
14+
- `opentelemetry-instrumentation-flask` Fix non-recording span bug
15+
([#999])(https://github.com/open-telemetry/opentelemetry-python-contrib/pull/999)
16+
- `opentelemetry-instrumentation-tornado` Fix non-recording span bug
17+
([#999])(https://github.com/open-telemetry/opentelemetry-python-contrib/pull/999)
1418

1519
## [1.10.0-0.29b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.10.0-0.29b0) - 2022-03-10
1620

1721
- `opentelemetry-instrumentation-wsgi` Capture custom request/response headers in span attributes
1822
([#925])(https://github.com/open-telemetry/opentelemetry-python-contrib/pull/925)
19-
2023
- `opentelemetry-instrumentation-flask` Flask: Capture custom request/response headers in span attributes
2124
([#952])(https://github.com/open-telemetry/opentelemetry-python-contrib/pull/952)
22-
2325
- `opentelemetry-instrumentation-tornado` Tornado: Capture custom request/response headers in span attributes
2426
([#950])(https://github.com/open-telemetry/opentelemetry-python-contrib/pull/950)
2527

@@ -37,6 +39,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3739

3840
### Fixed
3941

42+
- `opentelemetry-instrumentation-dbapi` Changed the format of traceparent id.
43+
([#941](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/941))
4044
- `opentelemetry-instrumentation-logging` retrieves service name defensively.
4145
([#890](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/890))
4246
- `opentelemetry-instrumentation-wsgi` WSGI: Conditionally create SERVER spans

instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/__init__.py

+6-9
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@
4545

4646
from opentelemetry import trace as trace_api
4747
from opentelemetry.instrumentation.dbapi.version import __version__
48-
from opentelemetry.instrumentation.utils import _generate_sql_comment, unwrap
48+
from opentelemetry.instrumentation.utils import (
49+
_generate_opentelemetry_traceparent,
50+
_generate_sql_comment,
51+
unwrap,
52+
)
4953
from opentelemetry.semconv.trace import SpanAttributes
5054
from opentelemetry.trace import Span, SpanKind, TracerProvider, get_tracer
5155

@@ -369,14 +373,7 @@ def _generate_comment(span: Span) -> str:
369373
span_context = span.get_span_context()
370374
meta = {}
371375
if span_context.is_valid:
372-
meta.update(
373-
{
374-
"trace_id": span_context.trace_id,
375-
"span_id": span_context.span_id,
376-
"trace_flags": span_context.trace_flags,
377-
"trace_state": span_context.trace_state.to_header(),
378-
}
379-
)
376+
meta.update(_generate_opentelemetry_traceparent(span))
380377
# TODO(schekuri): revisit to enrich with info such as route, db_driver etc...
381378
return _generate_sql_comment(**meta)
382379

instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/__init__.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,10 @@ def _start_response(status, response_headers, *args, **kwargs):
153153
otel_wsgi.add_response_attributes(
154154
span, status, response_headers
155155
)
156-
if span.kind == trace.SpanKind.SERVER:
156+
if (
157+
span.is_recording()
158+
and span.kind == trace.SpanKind.SERVER
159+
):
157160
otel_wsgi.add_custom_response_headers(
158161
span, response_headers
159162
)
@@ -204,7 +207,7 @@ def _before_request():
204207
] = flask.request.url_rule.rule
205208
for key, value in attributes.items():
206209
span.set_attribute(key, value)
207-
if span.kind == trace.SpanKind.SERVER:
210+
if span.is_recording() and span.kind == trace.SpanKind.SERVER:
208211
otel_wsgi.add_custom_request_headers(
209212
span, flask_request_environ
210213
)

instrumentation/opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ def _start_span(tracer, handler, start_time) -> _TraceContext:
340340
for key, value in attributes.items():
341341
span.set_attribute(key, value)
342342
span.set_attribute("tornado.handler", _get_full_handler_name(handler))
343-
if span.kind == trace.SpanKind.SERVER:
343+
if span.is_recording() and span.kind == trace.SpanKind.SERVER:
344344
_add_custom_request_headers(span, handler.request.headers)
345345

346346
activation = trace.use_span(span, end_on_exit=True)
@@ -395,7 +395,7 @@ def _finish_span(tracer, handler, error=None):
395395
description=otel_status_description,
396396
)
397397
)
398-
if ctx.span.kind == trace.SpanKind.SERVER:
398+
if ctx.span.is_recording() and ctx.span.kind == trace.SpanKind.SERVER:
399399
_add_custom_response_headers(ctx.span, handler._headers)
400400

401401
ctx.activation.__exit__(*finish_args) # pylint: disable=E1101

0 commit comments

Comments
 (0)