keptn / lifecycle-toolkit

Toolkit for cloud-native application lifecycle management
https://keptn.sh
Apache License 2.0
313 stars 122 forks source link

Add Evaluation Results in Trace #615

Closed thschue closed 1 year ago

thschue commented 1 year ago

At the moment, Evaluation Results are not written to the Trace (not sure if this wasn't already implemented). It would make sense to have this available in a format like:

Evaluation Result: <pass|fail>, Value: <Value>, Threshold: <Treshold>

thschue commented 1 year ago

FYI: @grabnerandi

nitinmewar commented 1 year ago

@thschue can I work on it?

prakrit55 commented 1 year ago

Hello @thschue I want to work on this issue, can you tell me what should I look for to solve this?

thschue commented 1 year ago

Sorry for the late reply, and thanks for the offer to work on this. @nitinmewar: do you still want to work on this?

nitinmewar commented 1 year ago

@thschue yes , I want to work on this. can you please provide little bit more details in order to fix this issue?

prakrit55 commented 1 year ago

hey @nitinmewar , I think you can modify the configuration of keptn quality gate service to include the details in JSON format. You just need to modify the evaluation-done event to include the details : )

thschue commented 1 year ago

hey @nitinmewar , I think you can modify the configuration of keptn quality gate service to include the details in JSON format. You just need to modify the evaluation-done event to include the details : )

Hey @prakrit55! In the lifecycle-toolkit this looks a bit different, there are no events atm :-)

thschue commented 1 year ago

@thschue yes , I want to work on this. can you please provide little bit more details in order to fix this issue?

Yes, We are running tasks in the KeptnTask Controller, and in this part we're issuing failed events in the OTel span: https://github.com/keptn/lifecycle-toolkit/blob/6a7b0c1328027c4111f8f7aba0641409f62a63ad/operator/controllers/common/evaluationhandler.go#L134.

The task would be to write more detailed results there.

nitinmewar commented 1 year ago

@thschue

this is what we need to change, right? ->

for k, v := range evaluation.Status.EvaluationStatus {
    if v.Status == apicommon.StateFailed {
        msg := fmt.Sprintf("evaluation of '%s' failed with value: '%s' and reason: '%s'", k, v.Value, v.Message)
        spanTrace.AddEvent(msg, trace.WithTimestamp(time.Now().UTC()))
        k8sEventMessage = fmt.Sprintf("%s\n%s", k8sEventMessage, msg)
        }
    } 

right now it only writes failed evaluations to trace. Do we want to write for both pass and fail, so it would look like this, right?

for k, v := range evaluation.Status.EvaluationStatus {
    var result string
    switch v.Status{
    case apicommon.StateSucceeded:
        result = "Pass"
    case apicommon.StateFailed:
        result = "Fail"
    }
    msg := fmt.Sprintf("evaluating '%s': result='%s', value='%s', threshold='%s', message='%s'", k, result, v.Value, v.Threshold, v.Message)
    spanTrace.AddEvent(msg, trace.WithTimestamp(time.Now().UTC()))
    k8sEventMessage = fmt.Sprintf("%s\n%s", k8sEventMessage, msg)
    }

And what is threshold?

am I going in a completely different direction here?

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

RealAnna commented 1 year ago

this issue is outdated, closing it