Description
Describe your environment.
I'm using the OpenCensus Azure extension (opencensus-ext-azure==1.1.7) with Python 3.10.7.
Steps to reproduce.
Create a trace with the AzureExporter (as describe in here: https://github.com/census-instrumentation/opencensus-python/tree/master/contrib/opencensus-ext-azure#trace) and add the http status code as an attribute:
import http
from opencensus.trace.attributes_helper import COMMON_ATTRIBUTES
span.add_attribute(
attribute_key=COMMON_ATTRIBUTES["HTTP_STATUS_CODE"],
attribute_value=http.HTTPStatus.OK,
)
What is the expected behavior?
The response code in Azure shows a string HTTPStatus.OK
.
What is the actual behavior?
The response code in Azure should show 200
.
Additional context.
It goes wrong because the attribute value is an IntEnum. The status_code is casted to a string (https://github.com/census-instrumentation/opencensus-python/blob/master/contrib/opencensus-ext-azure/opencensus/ext/azure/trace_exporter/__init__.py#L140-L143 and https://github.com/census-instrumentation/opencensus-python/blob/master/contrib/opencensus-ext-azure/opencensus/ext/azure/trace_exporter/__init__.py#L179-L180). The comparision with the integers goes okay, but the casting to a string gives an unexpected result here.