All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.snowflake.client.jdbc.telemetry.TelemetryUtil Maven / Gradle / Ivy

There is a newer version: 3.18.0
Show newest version
/*
 * Copyright (c) 2012-2019 Snowflake Computing Inc. All rights reserved.
 */
package net.snowflake.client.jdbc.telemetry;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import net.snowflake.client.core.ObjectMapperFactory;

public class TelemetryUtil
{
  private final static ObjectMapper mapper =
      ObjectMapperFactory.getObjectMapper();

  public final static String TYPE = "type";
  public final static String QUERY_ID = "query_id";
  public final static String VALUE = "value";

  /**
   * Create a simple TelemetryData instance for Job metrics using given parameters
   *
   * @param queryId the id of the query
   * @param field   the field to log (represents the "type" field in telemetry)
   * @param value   the value to log for the field
   * @return TelemetryData instance constructed from parameters
   */
  public static TelemetryData buildJobData(String queryId, TelemetryField field, long value)
  {
    ObjectNode obj = mapper.createObjectNode();
    obj.put(TYPE, field.toString());
    obj.put(QUERY_ID, queryId);
    obj.put(VALUE, value);
    return new TelemetryData(obj, System.currentTimeMillis());
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy