"github.com/volcengine/volc-sdk-golang/service/tls"
"github.com/volcengine/volc-sdk-golang/service/tls/pb"
"github.com/volcengine/volc-sdk-golang/service/tls/producer"
// When you initialize the client, we recommend that you use environment variables to dynamically get identity authentication information such as Volcano Engine AccessKey. Otherwise, hard-coded AccessKey information leads to data security risks.
// If you use Security Token Service (STS), use a temporary AccessKey ID and AccessKey secret, and set VOLCENGINE_TOKEN. If you do not use STS, leave VOLCENGINE_TOKEN empty.
tlsProducerCfg := producer.GetDefaultProducerConfig()
tlsProducerCfg.Endpoint = os.Getenv("VOLCENGINE_ENDPOINT")
tlsProducerCfg.Region = os.Getenv("VOLCENGINE_REGION")
tlsProducerCfg.AccessKeyID = os.Getenv("VOLCENGINE_ACCESS_KEY_ID")
tlsProducerCfg.AccessKeySecret = os.Getenv("VOLCENGINE_ACCESS_KEY_SECRET")
// Initialize and start the producer.
tlsProducer := producer.NewProducer(tlsProducerCfg)
// Specify topicId, source, and filename as needed.
topicID := "your-topic-id"
source := "your-log-source"
filename := "your-log-filename"
// Call SendLog offered by Go Producer to submit one log entry at a time.
// Customize a callback to handle business in the SendLog API request as needed.
err := tlsProducer.SendLog("", topicID, source, filename, &pb.Log{
Contents: []*pb.LogContent{
Time: time.Now().Unix(),
fmt.Println(err.Error())
// Call SendLogs offered by Go Producer to submit multiple log entries at a time.
// Customize a callback to handle business in the SendLogs API request as needed.
err = tlsProducer.SendLogs("", topicID, source, filename, &pb.LogGroup{
Contents: []*pb.LogContent{
Time: time.Now().Unix(),
Contents: []*pb.LogContent{
Time: time.Now().Unix(),
fmt.Println(err.Error())