Google\Cloud\Logging\V2\MetricsServiceV2Client::createLogMetric PHP Method

createLogMetric() public method

Sample code: try { $metricsServiceV2Client = new MetricsServiceV2Client(); $formattedParent = MetricsServiceV2Client::formatProjectName("[PROJECT]"); $metric = new LogMetric(); $response = $metricsServiceV2Client->createLogMetric($formattedParent, $metric); } finally { if (isset($metricsServiceV2Client)) { $metricsServiceV2Client->close(); } }
public createLogMetric ( string $parent, google\logging\v2\LogMetric $metric, array $optionalArgs = [] ) : google\logging\v2\LogMetric
$parent string The resource name of the project in which to create the metric: "projects/[PROJECT_ID]" The new metric must be provided in the request.
$metric google\logging\v2\LogMetric The new logs-based metric, which must not have an identifier that already exists.
$optionalArgs array { Optional. @type \Google\GAX\RetrySettings $retrySettings Retry settings to use for this call. If present, then $timeoutMillis is ignored. @type int $timeoutMillis Timeout to use for this call. Only used if $retrySettings is not set. }
return google\logging\v2\LogMetric
    public function createLogMetric($parent, $metric, $optionalArgs = [])
    {
        $request = new CreateLogMetricRequest();
        $request->setParent($parent);
        $request->setMetric($metric);
        $mergedSettings = $this->defaultCallSettings['createLogMetric']->merge(new CallSettings($optionalArgs));
        $callable = ApiCallable::createApiCall($this->metricsServiceV2Stub, 'CreateLogMetric', $mergedSettings, $this->descriptors['createLogMetric']);
        return $callable($request, [], ['call_credentials_callback' => $this->createCredentialsCallback()]);
    }