Describe your environment.
- Python 3.6.7, opencensus 0.5.0, opencensus-ext-stackdriver 0.3.0
- Instrumenting code running in a GKE Kubernetes cluster
Steps to reproduce.
Execute any tracing or stats collection code that exports to Stackdriver - the k8s metadata attributes will be missing from the results.
What is the expected behavior?
Results exported to Stackdriver should have associated attribute labels for project id, cluster name, pod name etc.
What is the actual behavior?
All k8s attributes are missing from the results I see in Stackdriver.
Additional context.
I think there is a bug in contrib/opencensus-ext-stackdriver/opencensus/ext/stackdriver/trace_exporter/__init__.py within set_monitored_resource_attributes:
def set_monitored_resource_attributes(span):
"""Set labels to span that can be used for tracing.
:param span: Span object
"""
resource = monitored_resource.get_instance()
if resource is not None:
resource_type = resource.get_type()
resource_labels = resource.get_labels()
if resource_type == 'gke_container':
resource_type = 'k8s_container'
...
This code is still checking for resources of type gke_container, whereas opencensus/common/monitored_resource/monitored_resource.py now uses k8s_container when populating the resources to be automatically added to the Stackdriver results. Therefore, the above if block is entirely skipped and no k8s attributes are included.
The same bug appears to be present in the equivalent file for Stackdriver stats exporting (gke_container is also present there).
Describe your environment.
Steps to reproduce.
Execute any tracing or stats collection code that exports to Stackdriver - the k8s metadata attributes will be missing from the results.
What is the expected behavior?
Results exported to Stackdriver should have associated attribute labels for project id, cluster name, pod name etc.
What is the actual behavior?
All k8s attributes are missing from the results I see in Stackdriver.
Additional context.
I think there is a bug in
contrib/opencensus-ext-stackdriver/opencensus/ext/stackdriver/trace_exporter/__init__.pywithinset_monitored_resource_attributes:This code is still checking for resources of type
gke_container, whereasopencensus/common/monitored_resource/monitored_resource.pynow usesk8s_containerwhen populating the resources to be automatically added to the Stackdriver results. Therefore, the above if block is entirely skipped and no k8s attributes are included.The same bug appears to be present in the equivalent file for Stackdriver stats exporting (
gke_containeris also present there).