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

OTel Log stdout Body shows as empty #5310

Closed
osherElm opened this issue May 7, 2024 · 1 comment · Fixed by #5311
Closed

OTel Log stdout Body shows as empty #5310

osherElm opened this issue May 7, 2024 · 1 comment · Fixed by #5311
Assignees
Labels
bug Something isn't working pkg:exporter:stdout Related to the stdout exporter package
Milestone

Comments

@osherElm
Copy link

osherElm commented May 7, 2024

Description

I am trying to use OTel logger with simple stdout and the Body is just not outputted

Environment

  • OS: Mac
  • Architecture: ARM
  • Go Version: 1.22
  • opentelemetry-go version: Release v1.26.0/v0.48.0/v0.2.0-alpha

Steps To Reproduce

package main

import (
	"context"
	"fmt"
	"time"

	"go.opentelemetry.io/otel/exporters/stdout/stdoutlog"
	log2 "go.opentelemetry.io/otel/log"
	"go.opentelemetry.io/otel/sdk/log"
)

func main() {
	processor, err := stdoutlog.New()
	if err != nil {
		fmt.Println(err.Error())
		return
	}

	p := log.NewLoggerProvider(log.WithProcessor(log.NewBatchProcessor(processor)))
	l := p.Logger("test-stdout")

	r := log2.Record{}
	r.SetBody(log2.StringValue("This body will not show"))
	r.SetSeverityText("FATAL")
	r.SetSeverity(log2.SeverityFatal)
	l.Emit(context.Background(), r)

	time.Sleep(5 * time.Second)

}

Mod:

	go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.51.0
	go.opentelemetry.io/otel v1.26.0
	go.opentelemetry.io/otel/metric v1.26.0
	go.opentelemetry.io/otel/trace v1.26.0

	go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.0.0-20240506090312-e0ed6a3028be // indirect
	go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.2.0-alpha // indirect
	go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.26.0 // indirect
	go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.26.0 // indirect
	go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.26.0 // indirect
	go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.26.0 // indirect
	go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.26.0 // indirect
	go.opentelemetry.io/otel/exporters/stdout/stdoutlog v0.2.0-alpha // indirect
	go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.26.0 // indirect
	go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.26.0 // indirect
	go.opentelemetry.io/otel/log v0.2.0-alpha // indirect
	go.opentelemetry.io/otel/sdk v1.26.0 // indirect
	go.opentelemetry.io/otel/sdk/log v0.2.0-alpha // indirect
	go.opentelemetry.io/otel/sdk/metric v1.26.0 // indirect
	go.opentelemetry.io/proto/otlp v1.2.0 // indirect

Output:

{"Timestamp":"0001-01-01T00:00:00Z","ObservedTimestamp":"2024-05-07T18:32:51.099086+03:00","Severity":21,"SeverityText":"FATAL",
"Body":{},"Attributes":[],"TraceID":"00000000000000000000000000000000","SpanID":"0000000000000000","TraceFlags":"00","Resource":[{"Key":"service.name",
"Value":{"Type":"STRING","Value":"unknown_service:___go_build_playground_git_otel"}},{"Key":"telemetry.sdk.language","Value":{"Type":"STRING","Value":"go"}},
{"Key":"telemetry.sdk.name","Value":{"Type":"STRING","Value":"opentelemetry"}},
{"Key":"telemetry.sdk.version","Value":{"Type":"STRING","Value":"1.26.0"}}],"Scope":{"Name":"test-stdout","Version":"","SchemaURL":""},"AttributeValueLengthLimit":0,"AttributeCountLimit":0}

Expected behavior

"Body":{}
should be:
"Body":{"This body will not show"}

@osherElm osherElm added the bug Something isn't working label May 7, 2024
@MrAlias MrAlias added the pkg:exporter:stdout Related to the stdout exporter package label May 7, 2024
@MrAlias
Copy link
Contributor

MrAlias commented May 7, 2024

cc @XSAM

@XSAM XSAM added this to the v1.27.0 milestone May 7, 2024
@XSAM XSAM self-assigned this May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pkg:exporter:stdout Related to the stdout exporter package
Projects
Status: Closed
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants