This document describes the Telemetry (OTLP) API, which implements the [OpenTelemetry Protocol](https://opentelemetry.io/docs/specs/otlp). This API is designed for use with applications that are instrumented by using one of the [OpenTelemetry SDKs](https://opentelemetry.io/docs/languages/) or that use any OpenTelemetry Collector.

<br />

OpenTelemetry is a Google Cloud-supported open source project with Google Cloud
engineers staffed to ensure support for ingesting and visualizing your
telemetry.

To learn more about this API, see the following reference documents:

- [v1.traces overview](https://docs.cloud.google.com/stackdriver/docs/reference/telemetry/v1.traces.md.txt)
- [v1.metrics overview](https://docs.cloud.google.com/stackdriver/docs/reference/telemetry/v1.metrics.md.txt)
- [v1.logs overview](https://docs.cloud.google.com/stackdriver/docs/reference/telemetry/v1.logs.md.txt)

For information about quotas associated with the API,
see [Telemetry API limits](https://docs.cloud.google.com/stackdriver/quotas.md.txt#telemetry-api-limits).

## Best practices

When instrumenting your applications to send trace data to your
Google Cloud project, we recommend that you use an exporter that
writes OTLP-formatted data to an [Collector](https://opentelemetry.io/docs/collector/),
which then sends your trace data to the Telemetry API.
In your collector, specify only the root URL:

    exporters:
      otlphttp:
        encoding: proto
        endpoint: https://telemetry.googleapis.com

OpenTelemetry detects the data type and automatically appends `/v1/traces`,
`/v1/metrics`, or `/v1/logs` as appropriate. For more information, see
[OTLP/HTTP Request](https://opentelemetry.io/docs/specs/otlp#otlphttp-request).

For examples that export trace or metric data to the Telemetry API,
see the following documents:

- [Overview of collector-based instrumentation samples](https://docs.cloud.google.com/stackdriver/docs/instrumentation/setup/sample-overview.md.txt).
- [OTLP ingestion overview](https://docs.cloud.google.com/stackdriver/docs/otlp/overview.md.txt).

When you can't use a collector, you can use an OpenTelemetry library that contains
an in-process OTLP exporter to send telemetry to the Telemetry API.
To learn how to directly export trace data, see
[Cloud Trace exporter to the OTLP endpoint](https://docs.cloud.google.com/stackdriver/docs/instrumentation/migrate-to-otlp-endpoints.md.txt).

## Authentication

You must configure your exporters with the credentials necessary to send
data to your Google Cloud project. For example, when you use collectors, typically
you use the `googleclientauth` extension to authenticate with Google
credentials.

For an example of authentication when using direct export of trace data, see
[Configure authentication](https://docs.cloud.google.com/stackdriver/docs/instrumentation/migrate-to-otlp-endpoints.md.txt#auth).
This example illustrates how to configure the exporter with your Google Cloud
[Application Default Credentials (ADC)](https://docs.cloud.google.com/docs/authentication/provide-credentials-adc.md.txt)
and add a language-specific Google Auth Library to your application.

To send telemetry data to your Google Cloud project by using the Telemetry API,
you must also do the following:

- Configure a quota project. To learn more, see
  [Set the quota project](https://docs.cloud.google.com/docs/quotas/set-quota-project.md.txt).

- Grant the following Identity and Access Management (IAM) roles to the user or to the
  service account that the application uses:

  - [Service Usage Consumer](https://docs.cloud.google.com/iam/docs/roles-permissions/serviceusage.md.txt#serviceusage.serviceUsageConsumer) role (`roles/serviceusage.serviceUsageConsumer`) on the quota project.
  - [Cloud Telemetry Writer](https://docs.cloud.google.com/iam/docs/roles-permissions/telemetry.md.txt#telemetry.writer) role (`roles/telemetry.writer`) on the project. This role lets your application write log, metric, and trace data.

## VPC Service Controls support

The Telemetry API service, whose service name is `telemetry.googleapis.com`,
is a VPC Service Controls-supported service. Any VPC Service Controls restrictions
that you create for the Telemetry API service apply
only to that service. Those restrictions don't apply to any
other services, including those like the `cloudtrace.googleapis.com` service,
which can also ingest trace data.

For more information, see the following:

- [VPC Service Controls documentation](https://docs.cloud.google.com/vpc-service-controls/docs.md.txt).
- [Supported products and limitations](https://docs.cloud.google.com/vpc-service-controls/docs/supported-products.md.txt).

## Service endpoints

A [service endpoint](https://google.aip.dev/9#api_service_endpoint)
is a base URL that specifies the
network address of an API service. The Telemetry API supports a global
endpoint and regional endpoints:

- Global endpoint: `telemetry.googleapis.com`. For this endpoint, after
  Google Cloud Observability successfully completes all validation steps, it sends the data
  to a backend service for storage.

- Regional endpoints: `telemetry.REGION.rep.googleapis.com`, where
  <var translate="no">REGION</var> is a supported region. For these endpoints, after Google Cloud Observability
  successfully completes all validation steps, it sends the data to a backend
  service. This service either stores or discards the data:

  - Log and trace data is stored. The backend service automatically moves data between regions when necessary.
  - Metric data is stored only when the location label attached to the data matches the endpoint's region or a zone within that region.

  For a list of supported regional endpoints, see the API reference pages.

The ingestion of trace data can trigger the creation of an observability bucket.
However, the use of a regional endpoint doesn't affect where the system creates
the observability bucket. The system determines the location of an
observability bucket using
[default settings](https://docs.cloud.google.com/stackdriver/docs/observability/set-defaults-for-observability-buckets.md.txt),
organization policies, and the set of supported bucket locations.