honeyhive.tracer.integration
Integration framework for HoneyHive tracer with external systems.
This module provides dynamic integration capabilities for OpenTelemetry providers, error handling, compatibility layers, and HTTP instrumentation. All components use dynamic logic patterns for flexible, extensible integration strategies.
IntegrationStrategy
Bases: Enum
Integration strategies for different provider types.
Source code in src/honeyhive/tracer/integration/detection.py
38 39 40 41 42 43 | |
MAIN_PROVIDER
class-attribute
instance-attribute
MAIN_PROVIDER = 'main_provider'
INDEPENDENT_PROVIDER
class-attribute
instance-attribute
INDEPENDENT_PROVIDER = 'independent_provider'
CONSOLE_FALLBACK
class-attribute
instance-attribute
CONSOLE_FALLBACK = 'console_fallback'
ProviderDetector
Dynamically detects and classifies existing OpenTelemetry TracerProviders.
Source code in src/honeyhive/tracer/integration/detection.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 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 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 | |
tracer_instance
instance-attribute
tracer_instance = tracer_instance
detect_provider_type
detect_provider_type() -> ProviderType
Dynamically detect the type of existing TracerProvider.
Returns:
| Name | Type | Description |
|---|---|---|
ProviderType |
ProviderType
|
The detected provider type |
Source code in src/honeyhive/tracer/integration/detection.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | |
get_integration_strategy
get_integration_strategy(
provider_type: Optional[ProviderType] = None,
) -> IntegrationStrategy
Dynamically determine integration strategy using Provider Intelligence.
This implements the Provider Strategy Intelligence: - Main Provider Strategy: Replace non-functioning providers (NoOp/Proxy/Empty) - Independent Provider Strategy: Coexist with functioning providers - Critical: Someone must process instrumentor spans - empty providers lose data
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider_type
|
Optional[ProviderType]
|
Optional provider type. If None, will detect automatically. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
IntegrationStrategy |
IntegrationStrategy
|
The recommended integration strategy |
Source code in src/honeyhive/tracer/integration/detection.py
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 | |
can_add_span_processor
can_add_span_processor() -> bool
Dynamically check if the current provider supports adding span processors.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if span processors can be added |
Source code in src/honeyhive/tracer/integration/detection.py
340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 | |
get_provider_info
Dynamically gather comprehensive provider information.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Dict[str, Any]
|
Provider information including type, name, and capabilities |
Source code in src/honeyhive/tracer/integration/detection.py
356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 | |
ProviderType
Bases: Enum
Types of OpenTelemetry TracerProviders.
Source code in src/honeyhive/tracer/integration/detection.py
29 30 31 32 33 34 35 | |
NOOP
class-attribute
instance-attribute
NOOP = 'noop'
TRACER_PROVIDER
class-attribute
instance-attribute
TRACER_PROVIDER = 'tracer_provider'
PROXY_TRACER_PROVIDER
class-attribute
instance-attribute
PROXY_TRACER_PROVIDER = 'proxy_tracer_provider'
CUSTOM
class-attribute
instance-attribute
CUSTOM = 'custom'
ErrorHandler
Dynamic error handler with extensible strategies and patterns.
Source code in src/honeyhive/tracer/integration/error_handling.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 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 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 | |
resilience_level
instance-attribute
resilience_level = resilience_level
tracer_instance
instance-attribute
tracer_instance = tracer_instance
handle_error
handle_error(
error: Exception,
component: str = "unknown",
operation: str = "unknown",
**metadata: Any
) -> bool
Dynamically handle error with appropriate recovery strategy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
error
|
Exception
|
Exception that occurred |
required |
component
|
str
|
Component where error occurred |
'unknown'
|
operation
|
str
|
Operation that failed |
'unknown'
|
**metadata
|
Any
|
Additional error metadata |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if error was handled successfully, False otherwise |
Source code in src/honeyhive/tracer/integration/error_handling.py
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 | |
get_error_statistics
Get dynamic error statistics.
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dictionary with error statistics |
Source code in src/honeyhive/tracer/integration/error_handling.py
561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 | |
IntegrationError
Bases: Exception
Base exception for integration errors with dynamic context.
Source code in src/honeyhive/tracer/integration/error_handling.py
23 24 25 26 27 28 29 30 31 32 33 34 35 | |
error_code
instance-attribute
error_code = error_code
details
instance-attribute
details = details or {}
ResilienceLevel
Bases: Enum
Resilience levels for dynamic error handling strategies.
Source code in src/honeyhive/tracer/integration/error_handling.py
103 104 105 106 107 108 | |
STRICT
class-attribute
instance-attribute
STRICT = 'strict'
BALANCED
class-attribute
instance-attribute
BALANCED = 'balanced'
RESILIENT
class-attribute
instance-attribute
RESILIENT = 'resilient'
ErrorProviderIncompatibleError
Bases: IntegrationError
Provider doesn't support required operations.
Source code in src/honeyhive/tracer/integration/error_handling.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
HTTPInstrumentation
Dynamic HTTP instrumentation for automatic request tracing.
Source code in src/honeyhive/tracer/integration/http.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 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 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 | |
tracer_instance
instance-attribute
tracer_instance = tracer_instance
instrument
instrument() -> None
Dynamically instrument HTTP libraries for automatic tracing.
Source code in src/honeyhive/tracer/integration/http.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | |
uninstrument
uninstrument() -> None
Dynamically remove HTTP instrumentation.
Source code in src/honeyhive/tracer/integration/http.py
518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 | |
get_instrumentation_status
Get dynamic instrumentation status.
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dictionary with instrumentation status information |
Source code in src/honeyhive/tracer/integration/http.py
604 605 606 607 608 609 610 611 612 613 614 615 616 | |
ProcessorIntegrationError
Bases: Exception
Base exception for processor integration errors.
Source code in src/honeyhive/tracer/integration/processor.py
22 23 | |
ProcessorIntegrator
Dynamically manages integration of HoneyHive processors with providers.
Source code in src/honeyhive/tracer/integration/processor.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 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 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 | |
tracer_instance
instance-attribute
tracer_instance = tracer_instance
integrate_with_provider
integrate_with_provider(
provider: TracerProvider,
source: str = "dev",
project: Optional[str] = None,
**kwargs: Any
) -> bool
Dynamically add HoneyHive processor to existing provider.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider
|
TracerProvider
|
The TracerProvider to integrate with |
required |
source
|
str
|
Source environment for span enrichment |
'dev'
|
project
|
Optional[str]
|
Optional project for span enrichment |
None
|
**kwargs
|
Any
|
Additional integration parameters |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if integration successful, False otherwise |
Raises:
| Type | Description |
|---|---|
ProviderIncompatibleError
|
If provider doesn't support span processors |
Source code in src/honeyhive/tracer/integration/processor.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | |
get_integrated_processors
get_integrated_processors() -> List[SpanProcessor]
Get list of processors that have been integrated.
Returns:
| Type | Description |
|---|---|
List[SpanProcessor]
|
List[SpanProcessor]: List of integrated HoneyHive processors |
Source code in src/honeyhive/tracer/integration/processor.py
349 350 351 352 353 354 355 356 | |
cleanup_processors
cleanup_processors() -> None
Dynamically clean up integrated processors.
This should be called during shutdown to ensure proper cleanup.
Source code in src/honeyhive/tracer/integration/processor.py
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 | |
ProviderIncompatibleError
Bases: ProcessorIntegrationError
Provider doesn't support required operations.
Source code in src/honeyhive/tracer/integration/processor.py
26 27 | |
enrich_session
enrich_session(
session_id: str,
metadata: Optional[Dict[str, Any]] = None,
tracer: Optional[Any] = None,
tracer_instance: Optional[Any] = None,
) -> None
LEGACY (v1.0+): Dynamically enrich session with metadata.
.. deprecated:: 1.0
This free function pattern is provided for backward compatibility only.
Use instance methods instead: tracer.enrich_session()
This pattern will be removed in v2.0.
Recommended Pattern (v1.0+): Use the tracer instance method for explicit tracer reference::
tracer = HoneyHiveTracer.init(api_key="...", project="...")
tracer.enrich_session(
metadata={"user_id": "user-456"},
user_properties={"plan": "premium"}
)
This function provides backward compatibility for the global enrich_session function using dynamic tracer discovery and flexible metadata handling.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session_id
|
str
|
The session ID to enrich |
required |
metadata
|
Optional[Dict[str, Any]]
|
Metadata dictionary to add to the session |
None
|
tracer
|
Optional[Any]
|
Optional tracer instance to use |
None
|
tracer_instance
|
Optional[Any]
|
Optional tracer instance for logging context |
None
|
Legacy Example
Using default tracer (backward compatibility)
enrich_session("session-123", {"user_id": "user-456"})
Using specific tracer (backward compatibility)
enrich_session("session-123", {"user_id": "user-456"}, tracer=my_tracer)
See Also
- :meth:
HoneyHiveTracer.enrich_session- Primary pattern (v1.0+) - :meth:
HoneyHiveTracer.enrich_span- Span enrichment
Source code in src/honeyhive/tracer/integration/compatibility.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
get_global_provider
Dynamically get the current global OpenTelemetry tracer provider.
Returns:
| Type | Description |
|---|---|
Any
|
The current global TracerProvider instance |
Example
from honeyhive.tracer.integration import get_global_provider provider = get_global_provider()
Source code in src/honeyhive/tracer/integration/detection.py
799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 | |
set_global_provider
set_global_provider(
provider: Any,
force_override: bool = False,
tracer_instance: Any = None,
) -> None
Dynamically set the global OpenTelemetry tracer provider.
This function properly handles OpenTelemetry's internal warnings when setting a tracer provider, using dynamic provider management techniques.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider
|
Any
|
The TracerProvider instance to set as global |
required |
force_override
|
bool
|
If True, allows overriding existing real providers (intended for test utilities and clean state management) |
False
|
tracer_instance
|
Any
|
Optional tracer instance for logging context |
None
|
Example
from opentelemetry.sdk.trace import TracerProvider from honeyhive.tracer.integration import set_global_provider provider = TracerProvider() set_global_provider(provider)
For test utilities - force override existing provider
set_global_provider(NoOpTracerProvider(), force_override=True)
Source code in src/honeyhive/tracer/integration/detection.py
694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 | |
with_error_handling
with_error_handling(
component: str = "unknown",
operation: str = "unknown",
resilience_level: ResilienceLevel = BALANCED,
tracer_instance: Any = None,
) -> Any
Decorator for dynamic error handling.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component
|
str
|
Component name for error context |
'unknown'
|
operation
|
str
|
Operation name for error context |
'unknown'
|
resilience_level
|
ResilienceLevel
|
Resilience level for error handling |
BALANCED
|
tracer_instance
|
Any
|
Optional tracer instance for logging context |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
Decorator function |
Source code in src/honeyhive/tracer/integration/error_handling.py
644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 | |