honeyhive.config.resolved
The resolved HoneyHive connection settings: the API keys and the API URL.
Three parts of the SDK send requests to HoneyHive on their own: the HoneyHive
client, the tracer (its OTLP export), and the CLI. Each is an entry point that
takes the keys and the URL as arguments and otherwise reads them from the
environment, and each used to do that reading itself, with its own variable
names in its own order, so one process could authenticate with one key in
evaluate() and another in a tracer, or send runs to one host and spans to
another, with no error anywhere. Now each entry point calls
ResolvedConfig.resolve once with the arguments it received, and everything
beneath it is handed the result; nothing below an entry point reads these
variables or resolves them again. The configuration models get their connection
fields from the environment_* functions here when a caller constructs one
directly, and from the tracer's resolved values when the tracer builds them.
Each setting has one preferred variable, HH_<SETTING>. The alternates in
_SETTINGS stay supported because shipped code read them and the changelog
of the release that added them names them. They are kept out of the README and
the docs site, reading one emits a DeprecationWarning once per process, and
removing one is a breaking change.
The ingestion API key and the data plane API key are typed: a present value
that is not an hh_ingst_ or an hh_fgdp_ key respectively raises here, at
resolution, whether or not the run goes on to send anything with it. The project
API key has no shape rule and is forwarded as given.
This type holds HoneyHive's canonical connection settings and nothing else. A new field is a deliberate decision about a canonical setting, never a convenience for a caller.
DEFAULT_API_URL
module-attribute
DEFAULT_API_URL = 'https://api.dp1.us.honeyhive.ai'
INGESTION_API_KEY_PREFIX
module-attribute
INGESTION_API_KEY_PREFIX = 'hh_ingst_'
DATA_PLANE_API_KEY_PREFIX
module-attribute
DATA_PLANE_API_KEY_PREFIX = 'hh_fgdp_'
ResolvedConfig
dataclass
The API keys and API URL after precedence has been applied.
api_key, ingestion_api_key, and data_plane_api_key are None when
nothing supplied them; whether that is an error is the consumer's decision,
since a tracer can run on an ingestion key alone while a Data Plane call
cannot.
Source code in src/honeyhive/config/resolved.py
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 | |
resolve
classmethod
resolve(
*,
api_key: Optional[str] = None,
ingestion_api_key: Optional[str] = None,
data_plane_api_key: Optional[str] = None,
api_url: Optional[str] = None
) -> ResolvedConfig
Merge an entry point's explicit arguments with the environment.
For each setting: the explicit argument if it is set, else the preferred variable, else the alternates in order. None and blank strings count as unset at every step. A present typed key is checked for shape, whichever step supplied it.
Raises:
| Type | Description |
|---|---|
TypeError
|
An explicit argument is neither None nor a string. |
ValueError
|
A typed key, explicit or from the environment, is not a key of its kind. The message names its source. |
Source code in src/honeyhive/config/resolved.py
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 | |
EnvSettingsSourceWithout
Bases: EnvSettingsSource
The built-in environment source, minus the fields the resolver owns.
Without this, pydantic-settings would read HH_API_KEY and, through the
prefix, HH_SERVER_URL on its own, and the latter would beat
HH_API_URL instead of ranking below it.
Source code in src/honeyhive/config/resolved.py
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 | |
get_field_value
Source code in src/honeyhive/config/resolved.py
360 361 362 363 364 365 | |
normalize_api_url
Apply the one shape rule for the API URL.
A value that is not an HTTP or HTTPS URL is malformed; the setting has a default, so the default is used with a warning rather than raising. A trailing slash is removed so request paths join without a double slash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str
|
A non-blank URL candidate. |
required |
source
|
str
|
The parameter or variable it came from, named in the warning. |
required |
Source code in src/honeyhive/config/resolved.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | |
check_ingestion_api_key
Return value if it is a well-formed ingestion API key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str
|
The candidate key, already known to be a non-blank string. |
required |
source
|
str
|
Where the value came from, named in the error, for example
|
required |
Returns:
| Type | Description |
|---|---|
str
|
The key with surrounding whitespace removed. |
Raises:
| Type | Description |
|---|---|
ValueError
|
|
Source code in src/honeyhive/config/resolved.py
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | |
check_data_plane_api_key
Return value if it is a well-formed fine-grained data plane API key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str
|
The candidate key, already known to be a non-blank string. |
required |
source
|
str
|
Where the value came from, named in the error, for example
|
required |
Returns:
| Type | Description |
|---|---|
str
|
The key with surrounding whitespace removed. |
Raises:
| Type | Description |
|---|---|
ValueError
|
|
Source code in src/honeyhive/config/resolved.py
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | |
environment_api_key
The project API key from the environment alone, or None when unset.
Source code in src/honeyhive/config/resolved.py
231 232 233 234 | |
environment_ingestion_api_key
The ingestion API key from the environment alone, checked; None when unset.
Raises:
| Type | Description |
|---|---|
ValueError
|
The variable is set to something other than an ingestion key. |
Source code in src/honeyhive/config/resolved.py
237 238 239 240 241 242 243 244 245 246 | |
environment_data_plane_api_key
The data plane API key from the environment alone, checked; None when unset.
Raises:
| Type | Description |
|---|---|
ValueError
|
The variable is set to something other than a fine-grained data plane API key. |
Source code in src/honeyhive/config/resolved.py
249 250 251 252 253 254 255 256 257 258 259 | |
environment_api_url
environment_api_url() -> str
The API URL from the environment alone, normalized; the default when unset.
Source code in src/honeyhive/config/resolved.py
262 263 264 265 266 267 | |
settings_sources
settings_sources(
settings_cls: type[BaseSettings],
init_settings: PydanticBaseSettingsSource,
dotenv_settings: PydanticBaseSettingsSource,
file_secret_settings: PydanticBaseSettingsSource,
*,
excluded: FrozenSet[str]
) -> Tuple[PydanticBaseSettingsSource, ...]
The source order for every HoneyHive configuration model.
Source code in src/honeyhive/config/resolved.py
368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 | |