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

Is formating for log messages actually implemented? #2628

Open
GeorgViehoever opened this issue Apr 4, 2024 · 6 comments
Open

Is formating for log messages actually implemented? #2628

GeorgViehoever opened this issue Apr 4, 2024 · 6 comments
Labels
bug Something isn't working do-not-stale documentation Improvements or additions to documentation good first issue Good for newcomers triage/accepted Indicates an issue or PR is ready to be actively worked on.

Comments

@GeorgViehoever
Copy link

I am trying to use formatting for log messages as suggested in

* @format an utf-8 string following https://messagetemplates.org/
. It does not seem to work.
Q: Is it actually implemented?
Q: Do you have an example code for me? Something like:

std::map<std::string, std::string> labelsTrace = {{"userId", "myUserId"}};
 logger->Trace(
 	  "traceLogMessage of user {userId}";
 	  labelsTrace);
@GeorgViehoever GeorgViehoever added the bug Something isn't working label Apr 4, 2024
@github-actions github-actions bot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Apr 4, 2024
@lalitb
Copy link
Member

lalitb commented Apr 4, 2024

Perhaps this needs to be documented better. The formatting of the message is not done by OpenTelemetry SDK, but the onus is on upstream agents or exporters who want the support.

@GeorgViehoever
Copy link
Author

I suggest to make this into a bug that requests to improve documentation. I believe I found nothing to this effect in the Docs or any code comments.

@lalitb lalitb added the documentation Improvements or additions to documentation label Apr 5, 2024
@esigo esigo added triage/accepted Indicates an issue or PR is ready to be actively worked on. good first issue Good for newcomers and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Apr 8, 2024
Copy link

This issue was marked as stale due to lack of activity.

@punya
Copy link
Member

punya commented Aug 28, 2024

Does the Logging API spec include support for a format string? (I wasn't able to find it.)

I was under the impression that the user-facing API should adhere closely to the spec. @ThomsonTan who originally added the API might know more about the design. For example, was the goal to propose format strings to the spec with C++ as a reference implementation?

@lalitb
Copy link
Member

lalitb commented Aug 28, 2024

I was under the impression that the user-facing API should adhere closely to the spec.

The otel-cpp logging API has two parts

  1. user-facing API
  2. bridge-api (rest of the code under opentelemetry::logs namespace)

Otel specs only specify the bridge-api which is used to create appenders for the use-facing API. The specs doesn't specify a user-facing API, as most languages already have their own logging frameworks.

Regarding format string, it is only part of user-facing api, and get referenced as LogRecord::body in bridge-api. The custom exporters, or upstream agents can do the actual formatting (if required).

@Annosha
Copy link

Annosha commented Oct 17, 2024

Hello @lalitb assuming this is a beginner friendly I'd like to work on this issue. Is it still open for contributions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working do-not-stale documentation Improvements or additions to documentation good first issue Good for newcomers triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

No branches or pull requests

5 participants