<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Shubham Chawla on Medium]]></title>
        <description><![CDATA[Stories by Shubham Chawla on Medium]]></description>
        <link>https://medium.com/@shubu_google?source=rss-2f6b8294b2ed------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*sSbtFJXBevxHot2q</url>
            <title>Stories by Shubham Chawla on Medium</title>
            <link>https://medium.com/@shubu_google?source=rss-2f6b8294b2ed------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 21:15:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shubu_google/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Mastering Observability in Google ADK: Implementing OpenTelemetry for GCP Metrics, Traces, and…]]></title>
            <link>https://medium.com/google-cloud/mastering-observability-in-google-adk-implementing-opentelemetry-for-gcp-metrics-traces-and-cf5422256633?source=rss-2f6b8294b2ed------2</link>
            <guid isPermaLink="false">https://medium.com/p/cf5422256633</guid>
            <category><![CDATA[observability]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[google-adk]]></category>
            <category><![CDATA[gcp]]></category>
            <category><![CDATA[opentelemetry]]></category>
            <dc:creator><![CDATA[Shubham Chawla]]></dc:creator>
            <pubDate>Mon, 06 Jul 2026 05:14:50 GMT</pubDate>
            <atom:updated>2026-07-06T15:42:10.951Z</atom:updated>
            <content:encoded><![CDATA[<h3>Mastering Observability in Google ADK: Implementing OpenTelemetry for GCP Metrics, Traces, and Logging</h3><p>Building autonomous generative AI agents using Google’s Agent Development Kit (ADK) is incredibly powerful. But as your LLM applications grow in complexity, understanding their reasoning, performance, and failure modes becomes a challenge. You can’t just rely on standard print statements when an agent autonomously decides which tools to use or how to break down a complex prompt.</p><p>To gain true visibility into your AI applications, you need robust observability. In this article, I will walk you through how to implement OpenTelemetry (OTel) in a Google ADK framework to export metrics, traces, and logging directly into Google Cloud Platform (GCP).</p><p>We will use the codebase from my GitHub repository (<a href="https://github.com/shubhamgoogle/gcp-opentelemetry-llm-agent">gcp-opentelemetry-llm-agent</a>) to demonstrate how to instrument your agent and validate the data in the GCP Console.</p><h3>Why OpenTelemetry for LLM Agents?</h3><p>Generative AI agents operate non-deterministically. Without instrumentation, you have zero insight into token usage, latency bottlenecks, or why an agent hallucinated. OpenTelemetry provides a standardized, vendor-agnostic way to collect this telemetry data.</p><p>By integrating OTel with Google Cloud Observability, you can:</p><ul><li><strong>Trace Agent Reasoning:</strong> Visualize the execution path of your agent, including sub-tasks and tool invocations.</li><li><strong>Monitor Metrics:</strong> Track token consumption, request latency, and custom metrics (like character or vowel counts).</li><li><strong>Centralize Logging:</strong> Correlate prompts and agent responses with specific trace spans for easy debugging.</li></ul><h3>Step 1: Setting Up the Dependencies</h3><p>Before diving into the code, ensure your requirements.txt is updated with the necessary OpenTelemetry and GCP export libraries.</p><pre># requirements.txt<br>google-cloud-trace<br>google-cloud-monitoring<br>google-cloud-logging<br>opentelemetry-api<br>opentelemetry-sdk<br>opentelemetry-exporter-gcp-trace<br>opentelemetry-exporter-gcp-monitoring<br>opentelemetry-instrumentation-google-genai</pre><p>Run pip install -r requirements.txt to pull in the dependencies.</p><h3>Step 2: Instrumenting the Agent</h3><p>The core of our observability setup lives in the agents/otel_agent/agent.py file. We need to initialize the OpenTelemetry providers and configure them to send data to GCP using the native exporters. We will also leverage the GoogleGenAiSdkInstrumentor to auto-instrument our model calls.</p><p>Here is how you can set up the logging, tracing and metrics configuration:</p><pre># agents/otel_agent/agent.py<br>import os<br>from opentelemetry import trace, metrics<br>from opentelemetry.sdk.trace import TracerProvider<br>from opentelemetry.sdk.trace.export import BatchSpanProcessor<br>from opentelemetry.sdk.metrics import MeterProvider<br>from opentelemetry.sdk.metrics.export import PeriodicExportingMetricReader<br>from opentelemetry.sdk.resources import Resource<br>import logging<br>from opentelemetry._logs import get_logger_provider, set_logger_provider<br>from opentelemetry.sdk._logs import LoggerProvider, LoggingHandler<br>from opentelemetry.sdk._logs.export import BatchLogRecordProcessor<br>from opentelemetry.exporter.cloud_logging import CloudLoggingExporter<br><br># GCP Exporters<br>from opentelemetry.exporter.cloud_trace import CloudTraceSpanExporter<br>from opentelemetry.exporter.cloud_monitoring import CloudMonitoringMetricsExporter<br># Google GenAI / ADK Instrumentation<br>from opentelemetry.instrumentation.google_genai import GoogleGenAiSdkInstrumentor<br>def initialize_gcp_telemetry(project_id: str):<br>    # 1. Define the Resource (Identifies your agent)<br>    resource = Resource.create({<br>        &quot;service.name&quot;: &quot;otel-llm-agent&quot;,<br>        &quot;service.version&quot;: &quot;1.0.0&quot;<br>    })<br>    # 2. Configure GCP Trace Exporter<br>    tracer_provider = TracerProvider(resource=resource)<br>    trace_exporter = CloudTraceSpanExporter(project_id=project_id)<br>    tracer_provider.add_span_processor(BatchSpanProcessor(trace_exporter))<br>    trace.set_tracer_provider(tracer_provider)<br>    # 3. Configure GCP Metrics Exporter<br>    metrics_exporter = CloudMonitoringMetricsExporter(project_id=project_id)<br>    metric_reader = PeriodicExportingMetricReader(metrics_exporter)<br>    meter_provider = MeterProvider(resource=resource, metric_readers=[metric_reader])<br>    metrics.set_meter_provider(meter_provider)<br>    # 4. Auto-Instrument the GenAI SDK<br>    GoogleGenAiSdkInstrumentor().instrument()<br>    <br>    return trace.get_tracer(__name__), metrics.get_meter(__name__)<br># Initialize when the agent starts<br>tracer, meter = initialize_gcp_telemetry(os.getenv(&quot;GOOGLE_CLOUD_PROJECT&quot;))<br># =========================================================================<br># Phase 1c: Logging Setup<br># =========================================================================<br>gcp_log_exporter = CloudLoggingExporter(project_id=&quot;deepspace-460917&quot;)<br>log_provider = get_logger_provider()<br><br>if hasattr(log_provider, &quot;add_log_record_processor&quot;):<br>    log_provider.add_log_record_processor(BatchLogRecordProcessor(gcp_log_exporter))<br>else:<br>    new_provider = LoggerProvider()<br>    new_provider.add_log_record_processor(BatchLogRecordProcessor(gcp_log_exporter))<br>    set_logger_provider(new_provider)<br>    log_provider = new_provider<br><br># Route Python&#39;s standard logging to OpenTelemetry<br>otel_handler = LoggingHandler(level=logging.INFO, logger_provider=log_provider)<br>logging.getLogger().addHandler(otel_handler)</pre><p>By calling GoogleGenAiSdkInstrumentor().instrument(), OpenTelemetry automatically formats prompts, responses, and multimodal data according to the GenAI semantic conventions, extracting attributes like gen_ai.usage.input_tokens and gen_ai.request.model.</p><h3>Step 3: Tracking Custom Metrics</h3><p>Metrics aggregate high-level numerical data over time, like request volume or token counts, you can use the OpenTelemetry Meter to create custom metrics like below.</p><pre># Create a custom counter metric<br>vowel_counter = meter.create_counter(<br>    &quot;agent.response.vowel_count&quot;,<br>    description=&quot;Number of vowels generated in the agent&#39;s response&quot;<br>)<br>def process_agent_response(response_text):<br>    # Calculate custom metric<br>    vowels = sum(1 for char in response_text.lower() if char in &quot;aeiou&quot;)<br>    <br>    # Record the metric with attributes<br>    vowel_counter.add(vowels, {&quot;model&quot;: &quot;gemini-1.5-pro&quot;})</pre><h3>Step 4: Tracking Custom Traces</h3><p>Traces organize the execution path into a hierarchy of “Spans,” creating a clear “waterfall” view of the agent’s reasoning loop. You can add custom spans and attributes to track specific internal functions or tool invocations that auto-instrumentation might miss.</p><pre>def execute_custom_tool(tool_input):<br>    # Start a custom span for a specific operation<br>    with tracer.start_as_current_span(&quot;execute_custom_tool&quot;) as span:<br>        # Add context to the span<br>        span.set_attribute(&quot;tool.input_length&quot;, len(tool_input))<br>        <br>        # Simulate tool execution<br>        result = f&quot;Processed data: {tool_input}&quot;<br>        <br>        span.set_attribute(&quot;tool.status&quot;, &quot;success&quot;)<br>        return result</pre><p><em>Note: Once exported, you can navigate to Cloud Trace in the Google Cloud Console to view the trace waterfall and visually inspect which spans are taking the longest, pointing you immediately to performance bottlenecks.</em></p><h3>Step 5: Tracking Custom logs</h3><p>Logs are detailed, timestamped records of discrete events. By default, sensitive data like prompt content and tool arguments might not be captured. You can enable capturing full prompts by setting the environment variable OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=true. This logs full prompt inputs and agent responses directly to Cloud Logging, which is highly useful for debugging.</p><p>To generate standard application logs that correlate with your active trace context:</p><pre>import logging<br>import google.cloud.logging<br>from opentelemetry.exporter.cloud_logging import CloudLoggingHandler<br># Attach Cloud Logging handler to standard Python logger<br>client = google.cloud.logging.Client()<br>handler = CloudLoggingHandler(client)<br>logger = logging.getLogger(&quot;gcp_agent_logger&quot;)<br>logger.setLevel(logging.INFO)<br>logger.addHandler(handler)<br>def log_agent_action(action, details):<br>    # Because of OTel, these logs will automatically inject the active trace_id<br>    logger.info(f&quot;Agent Action: {action} - Details: {details}&quot;)</pre><h3>Visualizing Telemetry in the GCP Console</h3><p>Once your agent is up and running, you can jump directly into the Google Cloud Console to view your performance data in real time.</p><p>1. Cloud Trace (Span Hierarchy)<br>In the Trace Explorer, you can visually track down bottlenecks by viewing the complete execution hierarchy of your agent, showing exactly how long your tool calls and LLM steps take.</p><figure><img alt="End-to-end trace view displaying the cascade of agent operations and API calls." src="https://cdn-images-1.medium.com/max/1024/1*R1yIef1aPsRZGt3-tuCWwQ.png" /></figure><p>2. Cloud Monitoring (Metrics &amp; PromQL)<br>Using the Metrics Explorer, you can write PromQL queries to build dashboards tracking custom counters, token distribution, or response rates.</p><pre>#PROMQL<br>sum by (agent_name) (<br>  increase({&quot;__name__&quot;=&quot;workload.googleapis.com/agent.prompt.vowel_count&quot;, &quot;monitored_resource&quot;=&quot;generic_task&quot;}[${__interval}])<br>)</pre><figure><img alt="Custom metrics visualization showing agent output behaviors over time." src="https://cdn-images-1.medium.com/max/1024/1*vuSMoS2r2EC4Y50IdKcXsQ.png" /></figure><p>3. Cloud Logging (Trace Context Correlation)<br>In the Logs Explorer, because OpenTelemetry automatically links your log statements to the current active trace context, you can seamlessly drill down into specific transaction flows.</p><pre>#LQL<br>severity&gt;=INFO<br>AND (textPayload:&quot;Agent starts execution for run_id&quot; OR jsonPayload.message:&quot;Agent starts execution for run_id&quot;)</pre><figure><img alt="Correlated application logs with injected OpenTelemetry Trace IDs." src="https://cdn-images-1.medium.com/max/1024/1*JOmeesrPqNfcsupQxdhYWA.png" /></figure><h3>Conclusion</h3><p>Instrumenting your LLM applications with OpenTelemetry transforms a “black box” agent into a highly observable, production-ready system. By leveraging the patterns in the <a href="https://github.com/shubhamgoogle/gcp-opentelemetry-llm-agent">shubhamgoogle/gcp-opentelemetry-llm-agent</a> repository, you can seamlessly route standard and custom metrics, traces, and logs to Google Cloud Observability, allowing you to monitor costs, optimize token usage, and rapidly debug complex AI reasoning loops.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf5422256633" width="1" height="1" alt=""><hr><p><a href="https://medium.com/google-cloud/mastering-observability-in-google-adk-implementing-opentelemetry-for-gcp-metrics-traces-and-cf5422256633">Mastering Observability in Google ADK: Implementing OpenTelemetry for GCP Metrics, Traces, and…</a> was originally published in <a href="https://medium.com/google-cloud">Google Cloud - Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hive to BigQuery: Move Data efficiently using GCP Dataproc Serverless]]></title>
            <link>https://medium.com/google-cloud/hive-to-bigquery-move-data-efficiently-using-gcp-dataproc-serverless-ee30d35aaf03?source=rss-2f6b8294b2ed------2</link>
            <guid isPermaLink="false">https://medium.com/p/ee30d35aaf03</guid>
            <category><![CDATA[hive]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[bigquery]]></category>
            <category><![CDATA[dataproc]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <dc:creator><![CDATA[Shubham Chawla]]></dc:creator>
            <pubDate>Wed, 19 Oct 2022 02:27:04 GMT</pubDate>
            <atom:updated>2022-10-19T02:27:04.114Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/826/1*ck_nDqG1Nzox583KDifHPw.jpeg" /></figure><p>One of the main requirements of any Cloud Migration activity is to migrate data from on-premise/cloud servers to modern data warehouses like BigQuery. Migrating data from Hadoop to BigQuery is a fairly common use case in the industry. It usually includes multistep process involving data migration to GCS using DistCP or other methods and then building a pipeline from GCS to BigQuery.</p><p><a href="https://github.com/GoogleCloudPlatform/dataproc-templates">Dataproc Templates</a> using <a href="https://cloud.google.com/vertex-ai/docs/tutorials/jupyter-notebooks">VertexAI notebook</a> and <a href="https://cloud.google.com/dataproc-serverless/docs">Dataproc Serverless</a> provides one stop solution to migrate data directly from Hive Tables from any Hadoop environment to GCP BigQuery.</p><p><strong>Setup VertexAI Notebook:</strong></p><ol><li>Enable below services in GCP project from <a href="https://console.developers.google.com/">API Console</a>:</li></ol><ul><li>Compute Engine API</li><li>Dataproc API</li><li>Vertex-AI API</li><li>Vertex Notebooks API</li></ul><p>2. Create a <a href="https://cloud.google.com/vertex-ai/docs/workbench/user-managed/introduction">User-Managed</a> Notebook in <a href="https://pantheon.corp.google.com/vertex-ai/workbench/list/instances">Vertex AI Workbench.</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/0*jtegDP1x9AGAGOeC.png" /></figure><p>3. Clone Dataproc Template GitHub repo using the GIT tab as shown in the below screenshot</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fxf16h5v4Ialq-4Ejv-LBQ.png" /></figure><p>or open a terminal from launcher window and clone using git clone.</p><pre>git clone <a href="https://github.com/GoogleCloudPlatform/dataproc-templates.git">https://github.com/GoogleCloudPlatform/dataproc-templates.git</a></pre><p>4. From the folders tab, open <a href="https://github.com/GoogleCloudPlatform/dataproc-templates/blob/main/notebooks/hive2bq/HiveToBigquery_notebook.ipynb">HiveToBigquery_notebook.ipynb</a> notebook present in the path: dataproc-templates/notebooks/hive2bq</p><p>5. For the convenience of users, following steps are marked sequentially and implemented in the Python notebook.</p><p><strong>Step 1: Install required packages<br></strong>Some of the packages needed for the migration needs to be installed separately as they are not available in the notebook e.g. PySpark, JDK, etc.</p><p><strong>Step 2: Set Google Cloud properties<br></strong>Below configurations need to be set before running the notebook:</p><ul><li>REGION: GCP Region to unload Hive tables in BQ.</li><li>GCS_STAGING_LOCATION: GCS bucket to store artefacts.</li><li>SUBNET: VPC Subnet</li><li>INPUT_HIVE_DATABASE: Hive database for input tables</li><li>INPUT_HIVE_TABLES: Comma separated Hive table names to move, to move all the tables from a database put &quot;*&quot;</li><li>OUTPUT_BIGQUERY_DATASET: BigQuery dataset for the output tables</li><li>TEMP_BUCKET: Temporary GCS bucket to store intermediate files</li><li>HIVE_METASTORE: Hive metastore URI</li><li>MAX_PARALLELISM: Number of parallel Dataproc Jobs to run (default=10)</li><li>HIVE_OUTPUT_MODE: Can be one of overwrite/append/ignore/errorifexists</li></ul><p><strong>Step 3: </strong>Import needed libraries like pandas and SparkSession.</p><p><strong>Step 4: </strong>Set current working directory to python folder as all the required artefacts are available there.</p><p><strong>Step 5: Build python egg package<br></strong>HiveToBigQuery notebook at the back end makes use of existing<a href="https://github.com/GoogleCloudPlatform/dataproc-templates/blob/main/python/dataproc_templates/hive/hive_to_bigquery.py"> Hive to BigQuery template</a>, which needs python package in the form of egg file.</p><p><strong>Step 6: Copy the artifacts to GCS bucket<br></strong>Copy the above package file along with existing main.py to the user provided GCS bucket.</p><p><strong>Step 7: Get HIVE tables<br></strong>In case the list of Hive tables to migrate is not provided by the user in Step 2, this cell will connect to the Hive thrift URI provided and get the list of all the tables present in the database using SparkSession.</p><p><strong>Step 8: Create Job Set<br></strong>Based on the MAX_PARALLELISM value provided in Step 2, multiple jobs will run in parallel to migrate HIVE tables to BigQuery using Dataproc Serverless batch jobs. Run this cell to group list of tables in sets which will then run in parallel.</p><p><strong>Step 9:</strong> Set Dataproc Template Properties like JAR paths and egg package path to be passed to the VertexAI pipeline.</p><p><strong>Step 10: Build Vertex AI Pipelines<br></strong>With the help of<a href="https://cloud.google.com/vertex-ai/docs/pipelines/dataproc-component"> Dataproc Serverless components for Vertex AI Pipelines</a>, a Dataproc serverless batch job can be triggered which at the back end will run HIVE to BQ template and load table sets (refer Step 8) to BigQuery in parallel.</p><p><strong>Step 11: Trigger job and update Audit table<br></strong>The final cell is responsible for triggering Vertex AI pipeline built in the previous step and also updating the status of each table set in the Audit table.</p><p>6. Run all the cells one by one or all at once using the option given in Menu bar. At the end of step 11, a link will get generated for each table set which can be used to monitor the jobs. Alternatively, detailed logs can be seen from <a href="https://console.cloud.google.com/dataproc/batches">Dataproc Batch UI</a> as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vaGsQxS-u70XMQoe.png" /><figcaption>VertexAI notebook DAG visualisation</figcaption></figure><h3>Audit Table</h3><p>The template stores audit data for each load in CSV format in GCS bucket provided.</p><p>In order to view the data create an external table pointing to the GCS bucket as below.</p><pre>CREATE EXTERNAL TABLE `&lt;project-id&gt;.&lt;dataset-name&gt;.hive_bq_audit`<br>(<br>  Source_DB_Name STRING,<br>  Source_Table_Set STRING,<br>  Target_DB_Name STRING,<br>  Target_Table_Set STRING,<br>  Job_Start_Time STRING,<br>  Job_End_Time STRING,<br>  Job_Status STRING<br>)<br>OPTIONS(<br>  format=&quot;CSV&quot;,<br>  uris=[&quot;gs://&lt;bucket-name&gt;/audit/*&quot;]<br>);</pre><p><strong>Limitations:</strong></p><ol><li><strong>Partitioned tables:<br></strong>The current version does not automatically create partitions in the BigQuery. In order to replicate Hive partitioning in BigQuery, DDL with partition and cluster columns has to be created manually. Once table structure is created in BigQuery, the above process will take care of inserting data into partitions. <a href="https://cloud.google.com/bigquery/docs/interactive-sql-translator">BigQuery translation API</a> can be used to convert Hive DDL to BigQuery format.<br>Note: Read through BigQuery partition limitations <a href="https://cloud.google.com/bigquery/docs/partitioned-tables#limitations">here</a>.</li><li><strong>Incremental load:<br></strong>The current version supports overwrite and append mode only. Change this value in Step 2 above based on the requirement.</li><li><strong>Kerberos Authentication:<br></strong>User has to implement Kerberos authentication themselves if needed.</li></ol><p>For any queries/suggestions reach out to: <br><a href="/service/mailto:dataproc-templates-support-external@googlegroups.com">dataproc-templates-support-external@googlegroups.com</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ee30d35aaf03" width="1" height="1" alt=""><hr><p><a href="https://medium.com/google-cloud/hive-to-bigquery-move-data-efficiently-using-gcp-dataproc-serverless-ee30d35aaf03">Hive to BigQuery: Move Data efficiently using GCP Dataproc Serverless</a> was originally published in <a href="https://medium.com/google-cloud">Google Cloud - Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>