Skip to content

Warning on OpenTelemetry when some attributes are not set #1385

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

Closed
jeremietharaud opened this issue Oct 12, 2022 · 1 comment · Fixed by #1567
Closed

Warning on OpenTelemetry when some attributes are not set #1385

jeremietharaud opened this issue Oct 12, 2022 · 1 comment · Fixed by #1567
Labels
api: bigquery Issues related to the googleapis/python-bigquery API.

Comments

@jeremietharaud
Copy link

Environment details

  • OS type and version: Windows 10 21H2
  • Python version: 3.9.4
  • pip version: 22.2.2
  • google-cloud-bigquery version: 3.3.5

Steps to reproduce

  1. Set up a query job with opentelemetry enabled
  2. See warning in the console: Invalid type NoneType for attribute value. Expected one of ['bool', 'str', 'bytes', 'int', 'float'] or a sequence of those types

Code example

import logging
from google.cloud import bigquery
from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import (
    SimpleSpanProcessor,
    ConsoleSpanExporter,
)

provider = TracerProvider()
simple_processor = SimpleSpanProcessor(ConsoleSpanExporter())
provider.add_span_processor(simple_processor)
trace.set_tracer_provider(provider)

logging.basicConfig(level=10)

# Construct a BigQuery client object.
client = bigquery.Client()

query = "SELECT 1;"

query_job = client.query(query)

Stack trace

DEBUG:google.auth._default:Checking None for explicit credentials as part of auth process...
DEBUG:google.auth._default:Checking Cloud SDK credentials as part of auth process...
DEBUG:google.auth._default:Checking None for explicit credentials as part of auth process...
DEBUG:google.auth._default:Checking Cloud SDK credentials as part of auth process...
WARNING:opentelemetry.attributes:Invalid type NoneType for attribute value. Expected one of ['bool', 'str', 'bytes', 'int', 'float'] or a sequence of those types
WARNING:opentelemetry.attributes:Invalid type NoneType for attribute value. Expected one of ['bool', 'str', 'bytes', 'int', 'float'] or a sequence of those types
DEBUG:urllib3.util.retry:Converted retries value: 3 -> Retry(total=3, connect=None, read=None, redirect=None, status=None)
DEBUG:google.auth.transport.requests:Making request: POST https://oauth2.googleapis.com/token
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): oauth2.googleapis.com:443
DEBUG:urllib3.connectionpool:https://oauth2.googleapis.com:443 "POST /token HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): bigquery.googleapis.com:443
DEBUG:urllib3.connectionpool:https://bigquery.googleapis.com:443 "POST /bigquery/v2/projects/my-project/jobs?prettyPrint=false HTTP/1.1" 200 None
{
    "name": "BigQuery.job.begin",
    "context": {
        "trace_id": "0x192a0e4ec554c63f68525922208fed88",
        "span_id": "0xfa29f0363122c4c4",
        "trace_state": "[]"
    },
    "kind": "SpanKind.INTERNAL",
    "parent_id": null,
    "start_time": "2022-10-12T09:41:57.259114Z",
    "end_time": "2022-10-12T09:41:57.934410Z",
    "status": {
        "status_code": "UNSET"
    },
    "attributes": {
        "db.system": "BigQuery",
        "db.name": "my-project",
        "job_id": "fc1581e3-708b-4b51-9a05-e3ad52c68dec",
        "hasErrors": false,
        "num_child_jobs": 0,
        "path": "/projects/my-project/jobs"
    },
    "events": [],
    "links": [],
    "resource": {
        "attributes": {
            "telemetry.sdk.language": "python",
            "telemetry.sdk.name": "opentelemetry",
            "telemetry.sdk.version": "1.13.0",
            "service.name": "unknown_service"
        },
        "schema_url": ""
    }
}

Analysis

Warnings appear when location and job state attributes are not set.

@product-auto-label product-auto-label bot added the api: bigquery Issues related to the googleapis/python-bigquery API. label Oct 12, 2022
@JoonasMaanonen
Copy link

JoonasMaanonen commented Jan 3, 2023

I got this warning as well.

I think the warning disappears after adding similar None handling that was done in #1327 for the location and state fields.

location: https://github.com/googleapis/python-bigquery/blob/main/google/cloud/bigquery/opentelemetry_tracing.py#L104

state: https://github.com/googleapis/python-bigquery/blob/main/google/cloud/bigquery/opentelemetry_tracing.py#L111

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the googleapis/python-bigquery API.
Projects
None yet
2 participants