server: set default service.name in opentelemetry exporter

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8169
GitOrigin-RevId: 0aac41869d6d9a100825f7a90fb976b75c006875
This commit is contained in:
awjchen 2023-04-19 10:14:59 -06:00 committed by hasura-bot
parent 832fac9c69
commit 5e97a1e475
2 changed files with 32 additions and 5 deletions

View File

@ -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

View File

@ -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,6 +388,7 @@ parseOtelExporterConfig otelStatus env OtelExporterConfig {..} = do
{ requestHeaders = headers ++ requestHeaders uriRequest
},
_oteleiResourceAttributes =
Map.fromList $
map
(\NameValue {nv_name, nv_value} -> (nv_name, nv_value))
_oecResourceAttributes
@ -389,7 +397,7 @@ parseOtelExporterConfig otelStatus env OtelExporterConfig {..} = do
getOtelExporterTracesBaseRequest :: OtelExporterInfo -> Request
getOtelExporterTracesBaseRequest = _oteleiTracesBaseRequest
getOtelExporterResourceAttributes :: OtelExporterInfo -> [(Text, Text)]
getOtelExporterResourceAttributes :: OtelExporterInfo -> Map Text Text
getOtelExporterResourceAttributes = _oteleiResourceAttributes
data OtelBatchSpanProcessorInfo = OtelBatchSpanProcessorInfo