Skip to content
This repository was archived by the owner on Sep 17, 2025. It is now read-only.
This repository was archived by the owner on Sep 17, 2025. It is now read-only.

Invalid point value type error. MeasureInts being silently converted to ValueDouble #679

@mcnamam

Description

@mcnamam

Describe your environment. Describe any aspect of your environment relevant to the problem, including your Python version, [platform]
Linux, Python 2.7, opencensus 0.6.0, opencensus-ext-stackdriver 0.4.0

I recently upgraded my opencensus client from 0.3.1 to 0.6.0 to get the fix for #350
Now I am encountering the following error when running my script that publishes metrics via opencensus:
ERROR:opencensus.metrics.transport:Error handling metric export
Traceback (most recent call last):
File "/python_venv/local/lib/python2.7/site-packages/opencensus/metrics/transport.py", line 57, in func
return self.func(*aa, **kw)
File "/python_venv/local/lib/python2.7/site-packages/opencensus/metrics/transport.py", line 98, in export_all
export(get())
File "/python_venv/local/lib/python2.7/site-packages/opencensus/ext/stackdriver/stats_exporter/init.py", line 156, in export_metrics
metrics = list(metrics)
File "/python_venv/local/lib/python2.7/site-packages/opencensus/stats/measure_to_view_map.py", line 152, in get_metrics
metric = metric_utils.view_data_to_metric(vd, timestamp)
File "/python_venv/local/lib/python2.7/site-packages/opencensus/stats/metric_utils.py", line 132, in view_data_to_metric
return metric.Metric(md, ts_list)
File "/python_venv/local/lib/python2.7/site-packages/opencensus/metrics/export/metric.py", line 43, in init
self._check_type()
File "/python_venv/local/lib/python2.7/site-packages/opencensus/metrics/export/metric.py", line 69, in _check_type
raise ValueError("Invalid point value type")
ValueError: Invalid point value type

I added some print lines to metric.py to get a better idea of what type mismatch it was encountering and here's what I see:
view bytes_avail_view has metric desc MetricDescriptor(name="bytes_avail_view", description="bytes available under /storage across all hosts", unit=By, type=ValueLong)
ts is TimeSeries([ValueDouble(1.22790525338e+12)], label_values=(), start_timestamp=2019-06-06T21:28:29.757175Z)
check type is <class 'opencensus.metrics.export.value.ValueLong'>

This is my declaration for my bytes_avail measure and view:
BYTES_AVAIL_MEASURE = measure.MeasureInt("bytes_avail", "number of bytes available under /storage", Unit.BYTE)
BYTES_AVAIL_VIEW = view.View('bytes_avail_view', "bytes available under /storage across all hosts", [], BYTES_AVAIL_MEASURE, aggregation.SumAggregation())

It seems that somewhere my measure is being converted to ValueDouble resulting in the type mismatch error. I've tried paring down my script to just publish this measure once like so
measure_map.measure_int_put(BYTES_AVAIL_MEASURE, 1)
and I still get this type mismatch error.

Steps to reproduce.
Declare a MeasureInt using a sum aggregation (and maybe other types of aggregations) then try to publish it to Stackdriver.

What is the expected behavior?
No error thrown, type should be ValueLong at all times

What is the actual behavior?
The measure is being converted from ValueLong to ValueDouble at some point

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions