*** Settings ***
Documentation    Integration tests for metrics collection framework
Resource         ${CURDIR}/common.resource
Suite Setup      Setup Test Environment
Suite Teardown   Cleanup Test Environment

*** Variables ***
${HELPER}    ${CURDIR}/helper_metrics_collection.py

*** Test Cases ***
MetricType Enum Has Three Members
    [Documentation]    MetricType should have HISTOGRAM, COUNTER, GAUGE
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    metric-type-enum    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    metrics-type-enum-ok

All 14 Metric Definitions Exist
    [Documentation]    METRIC_DEFINITIONS should have 14 entries
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    metric-definitions    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    metrics-definitions-ok

Histogram Counter Gauge Factory Methods
    [Documentation]    Typed factory methods should set correct metric_type
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    typed-factories    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    metrics-typed-factories-ok

All 14 Convenience Methods
    [Documentation]    All 14 convenience methods should produce correct keys
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    convenience-methods    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    metrics-convenience-ok

MetricsEmitter Local Mode
    [Documentation]    MetricsEmitter emits structured log entries
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    emitter-local    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    metrics-emitter-local-ok

MetricsEmitter Disabled
    [Documentation]    MetricsEmitter respects disabled setting
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    emitter-disabled    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    metrics-emitter-disabled-ok

Metrics Settings Configuration
    [Documentation]    Settings should expose metrics_enabled and metrics_export_prometheus
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    settings-config    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    metrics-settings-ok

Metrics Log Processor
    [Documentation]    Structlog processor should tag metric events
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    log-processor    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    metrics-processor-ok
