Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom fields in CLS #1424

Open
qby-ankul opened this issue Nov 6, 2024 · 7 comments
Open

custom fields in CLS #1424

qby-ankul opened this issue Nov 6, 2024 · 7 comments
Assignees

Comments

@qby-ankul
Copy link

Hi all,

I am trying to define my own fields in CLS. For the ALS it works as described, even if the documentation here is a bit thin. How do I have to pass the parameters to the logger? In ALS I pass them as an object, this does not work in CLS.

### Custom Fields { #custom-fields }

@renejeglinsky
Copy link
Contributor

Hi @qby-ankul,
just to clarify: CLS is SAP Cloud Logging Service and ALS is SAP Application Logging Service. Correct?

So the section you've linked contains information for both services. If I understand correctly, you experience that the docs for ALS are correct (even if they're thin) but for CLS the docs are incorrect and don't enable you to make it work. Right?

Could you give an example configuration that doesn't work? Is there an error message or sth alike that you can share?

@qby-ankul
Copy link
Author

Hi @renejeglinsky,

Yes, that's right.

We used the following code in ALS:
cds.log("logger").info(value, {"custom_field": field_value});

Which no longer works in CLS. In general, I would like the documentation to be more meaningful than how do I configure this. But also, how can I use it.

@renejeglinsky
Copy link
Contributor

Thanks @qby-ankul. So you're trying to use the same custom field in both, ALS and CLS, correct? I'm not sure if this is possible.

@sjvans Could you give some insights here?

@qby-ankul
Copy link
Author

Hi @renejeglinsky,

no, we switched from ALS to CLS. So far we have lived with it being displayed in msg. However, this is not a permanent solution. We would like it to be listed as a separate field as mentioned in the documentation or in ALS.

@sjvans
Copy link
Contributor

sjvans commented Nov 7, 2024

hi @qby-ankul

could you please elaborate on "this does not work in CLS"?

for me, it works no problem:

"cds": {
  "log": {
    "als_custom_fields": {
      "bla": 0
    },
    "cls_custom_fields": [
      "bla"
    ]
  }
}
const cds = require('@sap/cds')
const LOG = cds.log('foo')

module.exports = srv => {
  srv.on('bar', req => {
    LOG.info('baz', { bla: 'blub' })
  })
}

ALS:
Screenshot 2024-11-07 at 13 32 37

CLS:
Screenshot 2024-11-07 at 13 32 46

best,
sebastian

@qby-ankul
Copy link
Author

qby-ankul commented Nov 7, 2024

Hi @sjvans

unfortunately does not work for me: https://github.com/qby-ankul/cls-custom-fields-demo/blob/main/cls-log.json

I have created an example: https://github.com/qby-ankul/cls-custom-fields-demo/tree/main

The CLS is set up according to the documentation: Bind the Application to a User Provided Service
https://help.sap.com/docs/cloud-logging/cloud-logging/ingest-via-cloud-foundry-runtime?locale=en-US&version=Cloud

bonus bug, the generated readiness parameters doesn't work ...

@sjvans
Copy link
Contributor

sjvans commented Nov 7, 2024

hi @qby-ankul

the binding via user-provided service is the issue. we assume a "normal" binding that identifies the service. otherwise we can not reliably protect against false positives... but i'll see what we can do.

can confirm the broken readiness checks, but i'll need to reach out to the respective colleagues. as far as i can tell, we generate an mta that is compliant to the readiness-health-check-http-endpoint docs.

best,
sebastian

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants