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

SetAttributes/AddAttributes truncate strings down to 0-length #5691

Closed
gquintard opened this issue Aug 7, 2024 · 5 comments
Closed

SetAttributes/AddAttributes truncate strings down to 0-length #5691

gquintard opened this issue Aug 7, 2024 · 5 comments
Labels
question Further information is requested
Milestone

Comments

@gquintard
Copy link

Description

otel/sdk/log.SetAttributes and otel/sdk/log.AddAttributes (what's the difference between the two, by the way?) are essentially useless when give a string because Record.attributeValueLengthLimit default to 0 and isn't public. So all strings used as attributes are truncated down to the empty string.

Environment

Steps To Reproduce

         record := sdklog.Record{}
          record.SetAttributes(apilog.String("foo", "bar")) 
          record.WalkAttributes( func(kv apilog.KeyValue) bool { 
                          fmt.Printf("%+v: %+v\n",kv.Key, kv.Value) 
                          return true
                  })

You'll see a sad foo: with no bar in sight

Expected behavior

Having a sensible default for the string limit and/or a way to set it would be nice

@gquintard gquintard added the bug Something isn't working label Aug 7, 2024
@pellared
Copy link
Member

pellared commented Aug 7, 2024

You are not supposed to create sdklog.Record{} by yourself. Why would you do it?

@gquintard
Copy link
Author

ah, might be pebcak then. In short, I didn't see anything to create them in https://pkg.go.dev/go.opentelemetry.io/otel/sdk/[email protected]

The long version is that I'm writing an exporter for varnish logs, meaning I ingest logs from stdin (or from a file) and push them to otel, so the Logger seemed overkill and just creating a Record to feed to the Exporter seemed a lot simpler?

@pellared
Copy link
Member

pellared commented Aug 7, 2024

The long version is that I'm writing an exporter for varnish logs, meaning I ingest logs from stdin (or from a file) and push them to otel

You should supposed to create a "log bridge" that uses https://pkg.go.dev/go.opentelemetry.io/otel/log to push logs to otel. You can take a look at e.g. otellogrus for reference.

Related issue: open-telemetry/opentelemetry-go-contrib#5947

@gquintard
Copy link
Author

thank you, I'll have a look at this and will close the issue.

@pellared pellared added question Further information is requested response needed Waiting on user input before progress can be made and removed bug Something isn't working response needed Waiting on user input before progress can be made labels Aug 7, 2024
@pavel-raykov
Copy link

pavel-raykov commented Aug 12, 2024

Sorry, there is another case where creating a standalone sdklog.Record could be useful:

By default, the logs are emitted with the Emit method which does not return any status, i.e., the caller does not have any feedback on whether the log has been delivered or not. There is alternative method https://pkg.go.dev/go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp#Exporter.Export which actually takes sdklog.Record as input, so it would be useful if it were possible to construct sdklog.Record with custom attributeValueLengthLimit and pass it to the Export function.

Could you please comment if this makes sense?

@XSAM XSAM added this to the untracked milestone Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants