|
17 | 17 | use crate::options::InstrumentationClientInfo;
|
18 | 18 | use gax::options::RequestOptions;
|
19 | 19 |
|
| 20 | +// OpenTelemetry Semantic Convention Keys |
| 21 | +// See https://opentelemetry.io/docs/specs/semconv/http/http-spans/ |
| 22 | + |
| 23 | +/// Span Kind for OpenTelemetry interop. Always CLIENT for a span representing an outbound HTTP request. |
| 24 | +const KEY_OTEL_KIND: &str = "otel.kind"; |
| 25 | +/// Span Name for OpenTelemetry interop. Recommended to be "{http.request.method} {url.template}" if url.template is available, otherwise "{http.request.method}". |
| 26 | +const KEY_OTEL_NAME: &str = "otel.name"; |
| 27 | +/// Span Status for OpenTelemetry interop. Set to Error in the event of an unrecoverable error, for example network error, 5xx status codes. Unset otherwise (including 4xx codes for CLIENT spans). |
| 28 | +const KEY_OTEL_STATUS: &str = "otel.status"; |
| 29 | + |
| 30 | +/// Which RPC system is being used. Set to "http" for REST calls. |
| 31 | +const KEY_RPC_SYSTEM: &str = "rpc.system"; |
| 32 | +/// The HTTP request method, for example GET; POST; HEAD. |
| 33 | +const KEY_HTTP_REQUEST_METHOD: &str = "http.request.method"; |
| 34 | +/// The actual destination host name or IP address. May differ from the URL's host if overridden, for example myservice.googleapis.com; myservice-staging.sandbox.googleapis.com; 10.0.0.1. |
| 35 | +const KEY_SERVER_ADDRESS: &str = "server.address"; |
| 36 | +/// The actual destination port number. May differ from the URL's port if overridden, for example 443; 8080. |
| 37 | +const KEY_SERVER_PORT: &str = "server.port"; |
| 38 | +/// The absolute URL of the request, for example https://www.foo.bar/search?q=OpenTelemetry. |
| 39 | +const KEY_URL_FULL: &str = "url.full"; |
| 40 | +/// The URI scheme component identifying the used protocol, for example http; https. |
| 41 | +const KEY_URL_SCHEME: &str = "url.scheme"; |
| 42 | +/// The low-cardinality template of the absolute path, for example /v2/locations/{location}/projects/{project}/. |
| 43 | +const KEY_URL_TEMPLATE: &str = "url.template"; |
| 44 | +/// The nominal domain from the original URL, representing the intended service, for example myservice.googleapis.com. |
| 45 | +const KEY_URL_DOMAIN: &str = "url.domain"; |
| 46 | + |
| 47 | +/// The numeric HTTP response status code, for example 200; 404; 500. |
| 48 | +const KEY_HTTP_RESPONSE_STATUS_CODE: &str = "http.response.status_code"; |
| 49 | +/// A low cardinality a class of error the operation ended with. |
| 50 | +const KEY_ERROR_TYPE: &str = "error.type"; |
| 51 | +/// The ordinal number of times this request has been resent (e.g., due to retries or redirects). None for the first attempt. |
| 52 | +const KEY_HTTP_REQUEST_RESEND_COUNT: &str = "http.request.resend_count"; |
| 53 | + |
| 54 | +// Custom GCP Attributes |
| 55 | +/// Identifies the Google Cloud service, for example appengine; run; firestore. |
| 56 | +const KEY_GCP_CLIENT_SERVICE: &str = "gcp.client.service"; |
| 57 | +/// The version of the client library, for example v1.0.2. |
| 58 | +const KEY_GCP_CLIENT_VERSION: &str = "gcp.client.version"; |
| 59 | +/// The repository of the client library. Always "googleapis/google-cloud-rust". |
| 60 | +const KEY_GCP_CLIENT_REPO: &str = "gcp.client.repo"; |
| 61 | +/// The crate name of the client library, for example google-cloud-storage. |
| 62 | +const KEY_GCP_CLIENT_ARTIFACT: &str = "gcp.client.artifact"; |
| 63 | + |
20 | 64 | #[derive(Debug, Clone, PartialEq)]
|
21 | 65 | pub(crate) enum OtelStatus {
|
22 | 66 | Unset,
|
@@ -44,11 +88,11 @@ impl OtelStatus {
|
44 | 88 | #[derive(Debug, Clone)]
|
45 | 89 | pub(crate) struct HttpSpanInfo {
|
46 | 90 | // Attributes for OpenTelemetry SDK interop
|
47 |
| - /// Span Kind. Always CLIENT for a span representing an outbound HTTP request. |
| 91 | + /// Span Kind for OpenTelemetry interop. Always CLIENT for a span representing an outbound HTTP request. |
48 | 92 | otel_kind: String,
|
49 |
| - /// Span Name. Recommended to be "{http.request.method} {url.template}" if url.template is available, otherwise "{http.request.method}". |
| 93 | + /// Span Name for OpenTelemetry interop. Recommended to be "{http.request.method} {url.template}" if url.template is available, otherwise "{http.request.method}". |
50 | 94 | otel_name: String,
|
51 |
| - /// Span Status. Set to Error in the event of an unrecoverable error, for example network error, 5xx status codes. Unset otherwise (including 4xx codes for CLIENT spans). |
| 95 | + /// Span Status for OpenTelemetry interop. Set to Error in the event of an unrecoverable error, for example network error, 5xx status codes. Unset otherwise (including 4xx codes for CLIENT spans). |
52 | 96 | otel_status: OtelStatus,
|
53 | 97 |
|
54 | 98 | // OpenTelemetry Semantic Conventions
|
|
0 commit comments