diff --git a/docs/docs/enterprise/opentelemetry.mdx b/docs/docs/enterprise/opentelemetry.mdx index 9d25783839f..a86ecfd2b3e 100644 --- a/docs/docs/enterprise/opentelemetry.mdx +++ b/docs/docs/enterprise/opentelemetry.mdx @@ -185,6 +185,25 @@ Example using Console: width="745px" /> +Your observability tool may expect to receive certain resource attributes in order to provide full functionality; such +resource attributes must be set with this parameter. Many, but not all, of these resource attributes will be +[OpenTelemetry Semantic Conventions](https://opentelemetry.io/docs/concepts/semantic-conventions/). + +Hasura automatically sets some resource attributes. The values of such attributes can be overridden by specifying +your own value for the attribute using this parameter. + +#### Default resource attributes + +| Attribute | Type | Default | +| --------- | ---- | ------- | +| [service.name](https://opentelemetry.io/docs/reference/specification/resource/semantic_conventions/#service) | string | `hasura` | + +:::info Attribute type support + +Hasura currently only supports string-valued attributes. + +::: + ## Understanding traces Use your observability tool's UI to visualize and perform further analytics on trace data to monitor, diagnose and diff --git a/server/src-lib/Hasura/RQL/Types/OpenTelemetry.hs b/server/src-lib/Hasura/RQL/Types/OpenTelemetry.hs index 31f23718b1f..0fb874830ed 100644 --- a/server/src-lib/Hasura/RQL/Types/OpenTelemetry.hs +++ b/server/src-lib/Hasura/RQL/Types/OpenTelemetry.hs @@ -43,6 +43,8 @@ import Data.Aeson (FromJSON, ToJSON (..), (.!=), (.:), (.:?), (.=)) import Data.Aeson qualified as Aeson import Data.Bifunctor (first) import Data.Environment (Environment) +import Data.Map.Strict (Map) +import Data.Map.Strict qualified as Map import Data.Set (Set) import Data.Set qualified as Set import Data.Text qualified as Text @@ -341,7 +343,12 @@ data OtelExporterInfo = OtelExporterInfo _oteleiTracesBaseRequest :: Request, -- | Attributes to send as the resource attributes of an export request. We -- currently only support string-valued attributes. - _oteleiResourceAttributes :: [(Text, Text)] + -- + -- Using Data.Map.Strict over Data.Hashmap.Strict because currently the + -- only operations on data are (1) folding and (2) union with a small + -- map of default attributes, and Map should be is faster than HashMap for + -- the latter. + _oteleiResourceAttributes :: Map Text Text } -- | Smart constructor for 'OtelExporterInfo'. @@ -381,15 +388,16 @@ parseOtelExporterConfig otelStatus env OtelExporterConfig {..} = do { requestHeaders = headers ++ requestHeaders uriRequest }, _oteleiResourceAttributes = - map - (\NameValue {nv_name, nv_value} -> (nv_name, nv_value)) - _oecResourceAttributes + Map.fromList $ + map + (\NameValue {nv_name, nv_value} -> (nv_name, nv_value)) + _oecResourceAttributes } getOtelExporterTracesBaseRequest :: OtelExporterInfo -> Request getOtelExporterTracesBaseRequest = _oteleiTracesBaseRequest -getOtelExporterResourceAttributes :: OtelExporterInfo -> [(Text, Text)] +getOtelExporterResourceAttributes :: OtelExporterInfo -> Map Text Text getOtelExporterResourceAttributes = _oteleiResourceAttributes data OtelBatchSpanProcessorInfo = OtelBatchSpanProcessorInfo